[realppl 7] realppl integration with remote/local and unit tests
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments to provide feedback.
| 1 Warning | |
|---|---|
| :warning: | Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.) |
Generated by :no_entry_sign: Danger
/gemini summary
Summary of Changes
This pull request introduces a new query execution model based on "realtime pipelines" to enhance Firestore's query capabilities. It refactors core components to support a unified QueryOrPipeline type, allowing both traditional queries and new pipeline definitions to be processed consistently across the local store, sync engine, and remote communication layers. This lays the groundwork for more advanced query features and improves the flexibility of query processing.
Highlights
- Core Query Model Enhancement: Introduced
RealtimePipelineto represent a sequence of evaluable stages, andQueryOrPipeline/TargetOrPipelineas polymorphic types to encapsulate either traditionalQuery/Targetobjects or the newRealtimePipelineobjects. This provides a unified approach for handling various query types. - Extensive System Refactoring: Modified numerous components across the client API, local persistence, sync engine, and remote communication layers to adopt and process the new
QueryOrPipelineandTargetOrPipelinetypes, ensuring consistent behavior throughout the system. - Query-to-Pipeline Conversion: Implemented core logic to convert existing
Queryobjects into a series ofRealtimePipelinestages, ensuring backward compatibility and laying the groundwork for future pipeline-based optimizations and advanced query features. - Advanced Query Feature Support: Enhanced
LimitStagewithin the pipeline model to correctly supportlimitToLastqueries by handling negative limits during evaluation, expanding the expressive power of queries. - Pipeline Canonicalization & Testing: Added new unit tests (
canonify_eq_test.cc,pipeline_util_test.cc) to validate the canonical representation, equality, and hashing ofRealtimePipelineand its utility classes, which are crucial for consistent behavior in data structures like hash maps. - Local Pipeline Evaluation: Enabled the local documents view to evaluate
RealtimePipelineobjects directly against the local cache, including handling overlays and different pipeline source types, which is vital for offline query execution. - Serialization Updates: Updated the serialization logic to correctly encode and decode
RealtimePipelineobjects and their constituent stages and expressions, ensuring that pipeline definitions can be persisted and transmitted.
Changelog
- Firestore/Example/Firestore.xcodeproj/project.pbxproj
- Added
canonify_eq_test.ccto the Xcode project. - Reordered some existing test file entries (
timestamp_test.cc,comparison_test.cc).
- Added
- Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm
- Updated
ViewSnapshotconstructor calls to usecore::QueryOrPipeline.
- Updated
- Firestore/Example/Tests/API/FSTAPIHelpers.mm
- Updated
ViewSnapshotconstructor calls to usecore::QueryOrPipeline.
- Updated
- Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm
- Updated
query.target()toquery.target_or_pipeline().
- Updated
- Firestore/Example/Tests/SpecTests/FSTSpecTests.mm
- Updated
TargetDataconstruction and access to usecore::TargetOrPipeline.
- Updated
- Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm
- Updated
QueryListener::Createcalls to usecore::QueryOrPipeline.
- Updated
- Firestore/Source/API/FIRQuery.mm
- Updated
ListenToQueryto acceptcore::QueryOrPipeline.
- Updated
- Firestore/core/src/api/api_fwd.h
- Added forward declaration for
class RealtimePipeline.
- Added forward declaration for
- Firestore/core/src/api/document_reference.cc
- Updated
ListenToQueryto acceptcore::QueryOrPipeline.
- Updated
- Firestore/core/src/api/expressions.cc
- Added
Constant::value()getter.
- Added
- Firestore/core/src/api/expressions.h
- Added
const google_firestore_v1_Value& Constant::value() const;.
- Added
- Firestore/core/src/api/ordering.h
- Added
const std::shared_ptr<Expr> expr_shared() const;. - Added
Ordering WithReversedDirection() const;.
- Added
- Firestore/core/src/api/query_core.cc
- Updated
ListenToQueryto acceptcore::QueryOrPipeline.
- Updated
- Firestore/core/src/api/query_snapshot.cc
- Updated
QuerySnapshotto usesnapshot_.query_or_pipeline().Comparator().
- Updated
- Firestore/core/src/api/realtime_pipeline.cc
- Refactored
RealtimePipelineconstructor to usestd::unique_ptr<remote::Serializer>. - Added copy constructor and assignment operator for
RealtimePipeline. - Initialized
rewritten_stages_in the constructor usingcore::RewriteStages. - Removed
SetRewrittentStagesmethod. - Updated
evaluate_context()to returnEvaluateContext(serializer_.get())and beconst.
- Refactored
- Firestore/core/src/api/realtime_pipeline.h
- Updated
RealtimePipelineconstructor signature. - Added copy constructor and assignment operator declarations.
- Removed
SetRewrittentStagesdeclaration. - Updated
evaluate_context()declaration to beconst.
- Updated
- Firestore/core/src/api/stages.cc
- Made
DocumentsSourceinherit fromEvaluableStageand implemented itsEvaluatemethod. - Updated
DocumentsSourceto usestd::set<std::string>fordocuments_. - Updated
LimitStage::Evaluateto handle negative limits (forlimitToLast).
- Made
- Firestore/core/src/api/stages.h
- Updated
DocumentsSourceclass definition and inheritance. - Added
path()toCollectionSourceandcollection_id()toCollectionGroupSource. - Added
expr()toWhereandlimit()toLimitStage.
- Updated
- Firestore/core/src/core/core_fwd.h
- Added forward declaration for
class TargetOrPipeline.
- Added forward declaration for
- Firestore/core/src/core/event_manager.cc
- Updated
AddQueryListener,RemoveQueryListener,OnError,OnViewSnapshotsto useQueryOrPipeline. - Added
HARD_FAIL("Unimplemented")for pipeline cases inAddQueryListenerandRemoveQueryListener.
- Updated
- Firestore/core/src/core/event_manager.h
- Updated method signatures for
Listen,ListenToRemoteStore,StopListening,StopListeningToRemoteStoreOnly, andOnErrorto useQueryOrPipeline. - Changed
queries_map tostd::unordered_map<core::QueryOrPipeline, QueryListenersInfo>.
- Updated method signatures for
- Firestore/core/src/core/firestore_client.cc
- Updated
ListenToQueryandGetDocumentsFromLocalCacheto useQueryOrPipeline.
- Updated
- Firestore/core/src/core/firestore_client.h
- Updated
ListenToQuerymethod signature to useQueryOrPipeline.
- Updated
- Firestore/core/src/core/pipeline_run.cc
- Removed redundant
pipeline.SetRewrittentStagescall, asrewritten_stages_is now initialized in theRealtimePipelineconstructor.
- Removed redundant
- Firestore/core/src/core/pipeline_util.cc
- Introduced
QueryOrPipelineandTargetOrPipelineclasses asabsl::variantwrappers. - Implemented
operator==,Hash(),CanonicalId(),ToString()for bothQueryOrPipelineandTargetOrPipeline. - Implemented
MatchesAllDocuments(),has_limit(),Matches(),Comparator()forQueryOrPipeline. - Added
GetLastEffectiveSortOrderings,CanonifyConstant,CanonifyExpr,CanonifySortOrderings,CanonifyStage,CanonifyPipelinehelpers. - Added
PipelineFlavor,PipelineSourceTypeenums and associated helper functions. - Implemented
ToPipelineStages(const Query& query)to convert traditional queries to pipeline stages. - Added
ReverseOrderingsandWhereConditionsFromCursorhelpers.
- Introduced
- Firestore/core/src/core/pipeline_util.h
- Defined
QueryOrPipelineandTargetOrPipelineclasses. - Declared canonicalization, hashing, and comparison methods for new types.
- Declared pipeline analysis enums and helper functions.
- Declared
ToPipelineStagesfunction.
- Defined
- Firestore/core/src/core/query_listener.cc
- Updated
QueryListener::Createand constructor to acceptQueryOrPipeline. - Updated
OnViewSnapshotandRaiseInitialEventto usesnapshot.query_or_pipeline().
- Updated
- Firestore/core/src/core/query_listener.h
- Updated
QueryListenerclass to useQueryOrPipelinefor itsquery_member and related methods.
- Updated
- Firestore/core/src/core/sync_engine.cc
- Updated
Listen,ListenToRemoteStore,StopListening,StopListeningToRemoteStoreOnlyto useQueryOrPipeline. - Updated
AllocateTargetto takeTargetOrPipeline. - Updated
InitializeViewAndComputeSnapshotto takeQueryOrPipeline. - Updated
QueryViewclass to holdQueryOrPipeline. - Updated
query_views_by_query_andqueries_by_target_maps to useQueryOrPipeline.
- Updated
- Firestore/core/src/core/sync_engine.h
- Updated
QueryEventSourceandSyncEnginemethod signatures to useQueryOrPipelineandTargetOrPipeline. - Updated
QueryViewand internal map types to useQueryOrPipeline.
- Updated
- Firestore/core/src/core/sync_engine_callback.h
- Updated
OnErrormethod signature to useQueryOrPipeline.
- Updated
- Firestore/core/src/core/view.cc
- Updated
Viewconstructor to takeQueryOrPipeline. - Added
GetLimit,GetLimitType,GetLimitEdgeshelper functions to handle limits for bothQueryandRealtimePipeline. - Updated
ComputeDocumentChangesto use new limit helpers andquery_or_pipeline.Matches().
- Updated
- Firestore/core/src/core/view.h
- Updated
Viewconstructor andquery_member to useQueryOrPipeline. - Added declarations for limit helper functions.
- Updated
- Firestore/core/src/core/view_snapshot.cc
- Updated constructor and
FromInitialDocumentsto takeQueryOrPipeline. - Renamed
query()getter toquery_or_pipeline().
- Updated constructor and
- Firestore/core/src/core/view_snapshot.h
- Updated constructor and
FromInitialDocumentsto useQueryOrPipeline. - Renamed
query()getter toquery_or_pipeline().
- Updated constructor and
- Firestore/core/src/local/leveldb_migrations.cc
- Updated
RewriteTargetsCanonicalIdsto usetarget_data.target_or_pipeline().CanonicalId().
- Updated
- Firestore/core/src/local/leveldb_remote_document_cache.cc
- Updated
GetDocumentsMatchingQueryto useQueryOrPipelineand handle pipeline-specific collection path extraction.
- Updated
- Firestore/core/src/local/leveldb_remote_document_cache.h
- Updated
GetDocumentsMatchingQuerymethod signatures to useQueryOrPipeline.
- Updated
- Firestore/core/src/local/leveldb_target_cache.cc
- Updated
AddTarget,RemoveTarget,GetTargetto useTargetOrPipeline.
- Updated
- Firestore/core/src/local/leveldb_target_cache.h
- Updated
GetTargetmethod signature to useTargetOrPipeline.
- Updated
- Firestore/core/src/local/local_documents_view.cc
- Updated
GetDocumentsMatchingQueryto takeQueryOrPipeline. - Introduced
GetDocumentsMatchingPipelineandRetrieveMatchingLocalDocumentshelpers for local pipeline evaluation. - Introduced
GetOverlaysForPipelineto retrieve overlays for pipeline sources.
- Updated
- Firestore/core/src/local/local_documents_view.h
- Updated
GetDocumentsMatchingQuerymethod signatures to useQueryOrPipeline. - Added declarations for
GetDocumentsMatchingPipeline,RetrieveMatchingLocalDocuments, andGetOverlaysForPipeline.
- Updated
- Firestore/core/src/local/local_serializer.cc
- Updated
EncodeTargetDataandDecodeTargetDatato handleTargetOrPipelineandpipeline_queryprotobuf fields.
- Updated
- Firestore/core/src/local/local_store.cc
- Updated
AllocateTarget,GetTargetData,ExecuteQueryto useTargetOrPipelineorQueryOrPipeline. - Updated
target_id_by_target_map to useTargetOrPipeline.
- Updated
- Firestore/core/src/local/local_store.h
- Updated
AllocateTarget,GetTargetData,ExecuteQuerymethod signatures to useTargetOrPipelineorQueryOrPipeline. - Updated
target_id_by_target_map to useTargetOrPipeline.
- Updated
- Firestore/core/src/local/memory_remote_document_cache.cc
- Updated
GetDocumentsMatchingQueryto useQueryOrPipelineand handle pipeline-specific collection path extraction.
- Updated
- Firestore/core/src/local/memory_remote_document_cache.h
- Updated
GetDocumentsMatchingQuerymethod signatures to useQueryOrPipeline.
- Updated
- Firestore/core/src/local/memory_target_cache.cc
- Updated
AddTarget,RemoveTarget,GetTargetto useTargetOrPipeline.
- Updated
- Firestore/core/src/local/memory_target_cache.h
- Updated
GetTargetmethod signature to useTargetOrPipeline. - Updated
targets_map to useTargetOrPipeline.
- Updated
- Firestore/core/src/local/query_engine.cc
- Updated all relevant methods (
GetDocumentsMatchingQuery,CreateCacheIndexes,PerformQueryUsingIndex, etc.) to useQueryOrPipeline. - Explicitly skipped pipeline indexing in
CreateCacheIndexesandPerformQueryUsingIndex. - Simplified
NeedsRefilllogic for pipelines.
- Updated all relevant methods (
- Firestore/core/src/local/query_engine.h
- Updated all relevant method signatures to use
QueryOrPipeline.
- Updated all relevant method signatures to use
- Firestore/core/src/local/remote_document_cache.h
- Updated
GetDocumentsMatchingQuerymethod signatures to useQueryOrPipeline.
- Updated
- Firestore/core/src/local/target_cache.h
- Updated
GetTargetmethod signature to useTargetOrPipeline.
- Updated
- Firestore/core/src/local/target_data.cc
- Updated
TargetDataconstructor andtarget()getter to useTargetOrPipeline. - Updated
target_member toTargetOrPipeline.
- Updated
- Firestore/core/src/local/target_data.h
- Updated
TargetDataclass to encapsulateTargetOrPipeline.
- Updated
- Firestore/core/src/remote/remote_event.cc
- Added
IsSingleDocumentTargethelper. - Updated
HandleExistenceFilterandCreateRemoteEventto useTargetOrPipelineandIsSingleDocumentTarget.
- Added
- Firestore/core/src/remote/remote_store.cc
- Updated
RaiseWatchSnapshotto usetarget_data.target_or_pipeline().
- Updated
- Firestore/core/src/remote/serializer.cc
- Updated
EncodeTargetto handleTargetOrPipelineand encodepipeline_query. - Added
EncodeRealtimePipelineto serializeRealtimePipelineobjects. - Added
DecodePipelineTargetto deserializepipeline_query. - Added
DecodeStage,DecodeExpression,DecodeFunctionExpression,DecodeOrderinghelpers for deserializing pipeline components.
- Updated
- Firestore/core/src/remote/serializer.h
- Updated
EncodeTargetmethod signature. - Added declarations for
EncodeRealtimePipeline,DecodePipelineTarget, and variousDecodehelpers for pipeline components.
- Updated
- Firestore/core/test/unit/core/event_manager_test.cc
- Updated test mocks and calls to use
QueryOrPipeline.
- Updated test mocks and calls to use
- Firestore/core/test/unit/core/pipeline/canonify_eq_test.cc
- New file: Contains unit tests for canonicalization and equality of
RealtimePipelineandQueryOrPipelineobjects.
- New file: Contains unit tests for canonicalization and equality of
- Firestore/core/test/unit/core/pipeline/complex_test.cc
- Minor update to remove commented out code.
- Firestore/core/test/unit/core/pipeline/utils.cc
- Updated
TestSerializerto returnstd::unique_ptr<remote::Serializer>.
- Updated
- Firestore/core/test/unit/core/pipeline/utils.h
- Updated
TestSerializersignature.
- Updated
- Firestore/core/test/unit/core/pipeline_util_test.cc
- New file: Contains unit tests for
QueryOrPipelineandTargetOrPipelineequality, hashing, and their usage in unordered maps.
- New file: Contains unit tests for
- Firestore/core/test/unit/core/query_listener_test.cc
- Updated test mocks and calls to use
QueryOrPipeline.
- Updated test mocks and calls to use
- Firestore/core/test/unit/core/view_snapshot_test.cc
- Updated test calls to use
QueryOrPipeline.
- Updated test calls to use
- Firestore/core/test/unit/core/view_test.cc
- Updated test calls to use
QueryOrPipeline.
- Updated test calls to use
- Firestore/core/test/unit/local/counting_query_engine.cc
- Updated to use
QueryOrPipeline.
- Updated to use
- Firestore/core/test/unit/local/counting_query_engine.h
- Updated to use
QueryOrPipeline.
- Updated to use
- Firestore/core/test/unit/local/leveldb_local_store_test.cc
- Updated test suite instantiation to include
use_pipelineparameter.
- Updated test suite instantiation to include
- Firestore/core/test/unit/local/leveldb_migrations_test.cc
- Updated to use
TargetOrPipeline.
- Updated to use
- Firestore/core/test/unit/local/leveldb_query_engine_test.cc
- Updated test suite instantiation to include
use_pipelineparameter.
- Updated test suite instantiation to include
- Firestore/core/test/unit/local/leveldb_target_cache_test.cc
- Updated to use
TargetOrPipeline.
- Updated to use
- Firestore/core/test/unit/local/local_serializer_test.cc
- Added tests for
TargetDatawith pipelines. - Updated existing tests to use
TargetOrPipeline.
- Added tests for
- Firestore/core/test/unit/local/local_store_test.cc
- Updated to use
QueryOrPipelineandTargetOrPipeline. - Added
should_use_pipeline_flag for tests.
- Updated to use
- Firestore/core/test/unit/local/local_store_test.h
- Updated to use
QueryOrPipelineandTargetOrPipeline. - Added
should_use_pipeline_flag andConvertQueryToPipelinehelper for tests.
- Updated to use
- Firestore/core/test/unit/local/lru_garbage_collector_test.cc
- Updated to use
TargetOrPipeline.
- Updated to use
- Firestore/core/test/unit/local/memory_local_store_test.cc
- Updated test suite instantiation to include
use_pipelineparameter.
- Updated test suite instantiation to include
- Firestore/core/test/unit/local/memory_query_engine_test.cc
- Updated test suite instantiation to include
use_pipelineparameter.
- Updated test suite instantiation to include
- Firestore/core/test/unit/local/memory_target_cache.cc
- Updated to use
TargetOrPipeline.
- Updated to use
- Firestore/core/test/unit/local/memory_target_cache.h
- Updated to use
TargetOrPipeline.
- Updated to use
- Firestore/core/test/unit/local/query_engine_test.cc
- Updated to use
QueryOrPipeline. - Added
should_use_pipeline_flag for tests.
- Updated to use
- Firestore/core/test/unit/local/query_engine_test.h
- Updated to use
QueryOrPipeline. - Added
should_use_pipeline_flag andConvertQueryToPipelinehelper for tests.
- Updated to use
- Firestore/core/test/unit/local/remote_document_cache_test.cc
- Updated to use
QueryOrPipeline.
- Updated to use
- Firestore/core/test/unit/local/target_cache_test.cc
- Updated to use
TargetOrPipeline.
- Updated to use
- Firestore/core/test/unit/remote/fake_target_metadata_provider.cc
- Updated to use
TargetOrPipeline.
- Updated to use
- Firestore/core/test/unit/remote/remote_event_test.cc
- Updated to use
TargetOrPipeline.
- Updated to use
- Firestore/core/test/unit/remote/serializer_test.cc
- Updated to use
TargetOrPipeline. - Added tests for pipeline serialization.
- Updated to use
Activity
- The pull request was opened on 2025-05-13.
- A bot comment from Gemini Code Assist was added on 2025-05-13, providing usage instructions.
- Another bot comment from Danger was added on 2025-05-13, indicating a warning about a missing changelog entry.
- The author
wu-huirequested a summary from Gemini on 2025-07-24.
/gemini review