Skip to content

Commit d261cde

Browse files
Finish Index-Free queries (still disabled) (#4484)
1 parent 5465d14 commit d261cde

31 files changed

+1079
-107
lines changed

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180
297DC2B3C1EB136D58F4BA9C /* byte_string_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5342CDDB137B4E93E2E85CCA /* byte_string_test.cc */; };
181181
298E0F8F6EB27AA36BA1CE76 /* FIRQueryUnitTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = FF73B39D04D1760190E6B84A /* FIRQueryUnitTests.mm */; };
182182
29954A3172DDFE5133D91E24 /* FSTLevelDBSpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E02C20213FFB00B64F25 /* FSTLevelDBSpecTests.mm */; };
183+
2A0925323776AD50C1105BC0 /* counting_query_engine.cc in Sources */ = {isa = PBXBuildFile; fileRef = 99434327614FEFF7F7DC88EC /* counting_query_engine.cc */; };
183184
2A365DB6DF32631964FE690A /* stream_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5B5414D28802BC76FDADABD6 /* stream_test.cc */; };
184185
2A499CFB2831612A045977CD /* message_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = CE37875365497FFA8687B745 /* message_test.cc */; };
185186
2AAEABFD550255271E3BAC91 /* to_string_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = B68B1E002213A764008977EF /* to_string_apple_test.mm */; };
@@ -209,6 +210,7 @@
209210
2FA0BAE32D587DF2EA5EEB97 /* async_queue_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6FB467B208E9A8200554BA2 /* async_queue_test.cc */; };
210211
3040FD156E1B7C92B0F2A70C /* ordered_code_benchmark.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0473AFFF5567E667A125347B /* ordered_code_benchmark.cc */; };
211212
306E762DC6B829CED4FD995D /* target_id_generator_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB380CF82019382300D97691 /* target_id_generator_test.cc */; };
213+
3095316962A00DD6A4A2A441 /* counting_query_engine.cc in Sources */ = {isa = PBXBuildFile; fileRef = 99434327614FEFF7F7DC88EC /* counting_query_engine.cc */; };
212214
314D231A9F33E0502611DD20 /* sorted_set_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 549CCA4C20A36DBB00BCEB75 /* sorted_set_test.cc */; };
213215
31850B3D5232E8D3F8C4D90C /* memory_remote_document_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1CA9800A53669EFBFFB824E3 /* memory_remote_document_cache_test.cc */; };
214216
31A396C81A107D1DEFDF4A34 /* serializer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 61F72C5520BC48FD001A68CB /* serializer_test.cc */; };
@@ -328,6 +330,7 @@
328330
4DD59069842DF002BD46737B /* leveldb_persistence_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5C2989FEC97E94ADD2A0B7E5 /* leveldb_persistence_test.cc */; };
329331
4DF18D15AC926FB7A4888313 /* lru_garbage_collector_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 277EAACC4DD7C21332E8496A /* lru_garbage_collector_test.cc */; };
330332
4E0777435A9A26B8B2C08A1E /* remote_document_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7EB299CF85034F09CFD6F3FD /* remote_document_cache_test.cc */; };
333+
4E2E0314F9FDD7BCED60254A /* counting_query_engine.cc in Sources */ = {isa = PBXBuildFile; fileRef = 99434327614FEFF7F7DC88EC /* counting_query_engine.cc */; };
331334
4E8085FB9DBE40BAE11F0F4E /* fake_credentials_provider.cc in Sources */ = {isa = PBXBuildFile; fileRef = B60894F62170207100EBC644 /* fake_credentials_provider.cc */; };
332335
4EE1ABA574FBFDC95165624C /* delayed_constructor_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = D0A6E9136804A41CEC9D55D4 /* delayed_constructor_test.cc */; };
333336
4F5714D37B6D119CB07ED8AE /* orderby_spec_test.json in Resources */ = {isa = PBXBuildFile; fileRef = 54DA12A21F315EE100DD57A1 /* orderby_spec_test.json */; };
@@ -610,6 +613,7 @@
610613
733AFC467B600967536BD70F /* BasicCompileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE0761F61F2FE68D003233AF /* BasicCompileTests.swift */; };
611614
736C4E82689F1CA1859C4A3F /* XCTestCase+Await.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0372021401E00B64F25 /* XCTestCase+Await.mm */; };
612615
73866AA12082B0A5009BB4FF /* FIRArrayTransformTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73866A9F2082B069009BB4FF /* FIRArrayTransformTests.mm */; };
616+
7394B5C29C6E524C2AF964E6 /* counting_query_engine.cc in Sources */ = {isa = PBXBuildFile; fileRef = 99434327614FEFF7F7DC88EC /* counting_query_engine.cc */; };
613617
73E42D984FB36173A2BDA57C /* FSTEventAccumulator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0392021401F00B64F25 /* FSTEventAccumulator.mm */; };
614618
73FE5066020EF9B2892C86BF /* hard_assert_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 444B7AB3F5A2929070CB1363 /* hard_assert_test.cc */; };
615619
7400AC9377419A28B782B5EC /* objc_compatibility_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = B696858F221770F000271095 /* objc_compatibility_apple_test.mm */; };
@@ -902,6 +906,7 @@
902906
BC8DFBCB023DBD914E27AA7D /* query_listener_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7C3F995E040E9E9C5E8514BB /* query_listener_test.cc */; };
903907
BD6CC8614970A3D7D2CF0D49 /* exponential_backoff_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6D1B68420E2AB1A00B35856 /* exponential_backoff_test.cc */; };
904908
BDD2D1812BAD962E3C81A53F /* hashing_test_apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = B69CF3F02227386500B281C8 /* hashing_test_apple.mm */; };
909+
BDF3A6C121F2773BB3A347A7 /* counting_query_engine.cc in Sources */ = {isa = PBXBuildFile; fileRef = 99434327614FEFF7F7DC88EC /* counting_query_engine.cc */; };
905910
BE20AA2B4081C95A8FBA4117 /* memory_query_cache_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = BB644F9A3FB7EE4EA704E56A /* memory_query_cache_test.cc */; };
906911
BE767D2312D2BE84484309A0 /* event_manager_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6F57521E161450FAF89075ED /* event_manager_test.cc */; };
907912
BE92E16A9B9B7AD5EB072919 /* string_format_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CFD366B783AE27B9E79EE7A /* string_format_apple_test.mm */; };
@@ -1014,6 +1019,7 @@
10141019
DC1C711290E12F8EF3601151 /* array_sorted_map_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54EB764C202277B30088B8F3 /* array_sorted_map_test.cc */; };
10151020
DC48407370E87F2233D7AB7E /* statusor_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54A0352D20A3B3D7003E0143 /* statusor_test.cc */; };
10161021
DD213F68A6F79E1D4924BD95 /* Pods_Firestore_Example_macOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E42355285B9EF55ABD785792 /* Pods_Firestore_Example_macOS.framework */; };
1022+
DCD83C545D764FB15FD88B02 /* counting_query_engine.cc in Sources */ = {isa = PBXBuildFile; fileRef = 99434327614FEFF7F7DC88EC /* counting_query_engine.cc */; };
10171023
DD5976A45071455FF3FE74B8 /* string_win_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 79507DF8378D3C42F5B36268 /* string_win_test.cc */; };
10181024
DDBC6DB41D1A43CFF01288A2 /* field_value_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB356EF6200EA5EB0089B766 /* field_value_test.cc */; };
10191025
DDD219222EEE13E3F9F2C703 /* leveldb_transaction_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 88CF09277CFA45EE1273E3BA /* leveldb_transaction_test.cc */; };
@@ -1411,6 +1417,7 @@
14111417
74FBEFA4FE4B12C435011763 /* memory_mutation_queue_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = memory_mutation_queue_test.cc; sourceTree = "<group>"; };
14121418
7515B47C92ABEEC66864B55C /* field_transform_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = field_transform_test.cc; sourceTree = "<group>"; };
14131419
759E964B6A03E6775C992710 /* Pods_Firestore_Tests_macOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_Tests_macOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1420+
75E24C5CD7BC423D48713100 /* counting_query_engine.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = counting_query_engine.h; sourceTree = "<group>"; };
14141421
79507DF8378D3C42F5B36268 /* string_win_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = string_win_test.cc; sourceTree = "<group>"; };
14151422
79D4CD6A707ED3F7A6D2ECF5 /* view_testing.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = view_testing.h; sourceTree = "<group>"; };
14161423
7B65C996438B84DBC7616640 /* CodableTimestampTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CodableTimestampTests.swift; sourceTree = "<group>"; };
@@ -1427,6 +1434,7 @@
14271434
9765D47FA12FA283F4EFAD02 /* memory_lru_garbage_collector_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = memory_lru_garbage_collector_test.cc; sourceTree = "<group>"; };
14281435
97C492D2524E92927C11F425 /* Pods-Firestore_FuzzTests_iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_FuzzTests_iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_FuzzTests_iOS/Pods-Firestore_FuzzTests_iOS.release.xcconfig"; sourceTree = "<group>"; };
14291436
98366480BD1FD44A1FEDD982 /* Pods-Firestore_Example_macOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_macOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_macOS/Pods-Firestore_Example_macOS.debug.xcconfig"; sourceTree = "<group>"; };
1437+
99434327614FEFF7F7DC88EC /* counting_query_engine.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = counting_query_engine.cc; sourceTree = "<group>"; };
14301438
9CFD366B783AE27B9E79EE7A /* string_format_apple_test.mm */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.objcpp; path = string_format_apple_test.mm; sourceTree = "<group>"; };
14311439
A1C8236D0FBB4374D486D11D /* query_cache_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = query_cache_test.cc; sourceTree = "<group>"; };
14321440
A5466E7809AD2871FFDE6C76 /* view_testing.cc */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.cpp.cpp; path = view_testing.cc; sourceTree = "<group>"; };
@@ -1821,6 +1829,8 @@
18211829
54995F70205B6E1A004EFFA0 /* local */ = {
18221830
isa = PBXGroup;
18231831
children = (
1832+
99434327614FEFF7F7DC88EC /* counting_query_engine.cc */,
1833+
75E24C5CD7BC423D48713100 /* counting_query_engine.h */,
18241834
299752013F200FE5BAB1555B /* index_free_query_engine_test.cc */,
18251835
AE4A9E38D65688EE000EE2A1 /* index_manager_test.cc */,
18261836
73F1F73A2210F3D800E1F692 /* index_manager_test.h */,
@@ -3375,6 +3385,7 @@
33753385
9AC604BF7A76CABDF26F8C8E /* cc_compilation_test.cc in Sources */,
33763386
5556B648B9B1C2F79A706B4F /* common.pb.cc in Sources */,
33773387
08D853C9D3A4DC919C55671A /* comparison_test.cc in Sources */,
3388+
3095316962A00DD6A4A2A441 /* counting_query_engine.cc in Sources */,
33783389
AAA50E56B9A7EF3EFDA62172 /* create_noop_connectivity_monitor.cc in Sources */,
33793390
B49311BDE5EB6DF811E03C1B /* credentials_provider_test.cc in Sources */,
33803391
9774A6C2AA02A12D80B34C3C /* database_id_test.cc in Sources */,
@@ -3547,6 +3558,7 @@
35473558
079E63E270F3EFCA175D2705 /* cc_compilation_test.cc in Sources */,
35483559
18638EAED9E126FC5D895B14 /* common.pb.cc in Sources */,
35493560
1115DB1F1DCE93B63E03BA8C /* comparison_test.cc in Sources */,
3561+
2A0925323776AD50C1105BC0 /* counting_query_engine.cc in Sources */,
35503562
169D01E6FF2CDF994B32B491 /* create_noop_connectivity_monitor.cc in Sources */,
35513563
5686B35D611C1CFF6BFE7215 /* credentials_provider_test.cc in Sources */,
35523564
58E377DCCC64FE7D2C6B59A1 /* database_id_test.cc in Sources */,
@@ -3730,6 +3742,7 @@
37303742
0A52B47C43B7602EE64F53A7 /* cc_compilation_test.cc in Sources */,
37313743
1DB3013C5FC736B519CD65A3 /* common.pb.cc in Sources */,
37323744
555161D6DB2DDC8B57F72A70 /* comparison_test.cc in Sources */,
3745+
7394B5C29C6E524C2AF964E6 /* counting_query_engine.cc in Sources */,
37333746
70A25C4238429C53CCF7C4CA /* create_noop_connectivity_monitor.cc in Sources */,
37343747
F386012CAB7F0C0A5564016A /* credentials_provider_test.cc in Sources */,
37353748
1465E362F7BA7A3D063E61C7 /* database_id_test.cc in Sources */,
@@ -3913,6 +3926,7 @@
39133926
1E8A00ABF414AC6C6591D9AC /* cc_compilation_test.cc in Sources */,
39143927
1D71CA6BBA1E3433F243188E /* common.pb.cc in Sources */,
39153928
9C86EEDEA131BFD50255EEF1 /* comparison_test.cc in Sources */,
3929+
DCD83C545D764FB15FD88B02 /* counting_query_engine.cc in Sources */,
39163930
AAE47EEF4A19F0DC6E1847CE /* create_noop_connectivity_monitor.cc in Sources */,
39173931
4008AF7585844F12207FC2F5 /* credentials_provider_test.cc in Sources */,
39183932
1D618761796DE311A1707AA2 /* database_id_test.cc in Sources */,
@@ -4107,6 +4121,7 @@
41074121
08A9C531265B5E4C5367346E /* cc_compilation_test.cc in Sources */,
41084122
544129DA21C2DDC800EFB9CC /* common.pb.cc in Sources */,
41094123
548DB929200D59F600E00ABC /* comparison_test.cc in Sources */,
4124+
4E2E0314F9FDD7BCED60254A /* counting_query_engine.cc in Sources */,
41104125
B67BF449216EB43000CA9097 /* create_noop_connectivity_monitor.cc in Sources */,
41114126
ABC1D7DC2023A04B00BA84F0 /* credentials_provider_test.cc in Sources */,
41124127
ABE6637A201FA81900ED349A /* database_id_test.cc in Sources */,
@@ -4309,6 +4324,7 @@
43094324
338DFD5BCD142DF6C82A0D56 /* cc_compilation_test.cc in Sources */,
43104325
4C66806697D7BCA730FA3697 /* common.pb.cc in Sources */,
43114326
EC7A44792A5513FBB6F501EE /* comparison_test.cc in Sources */,
4327+
BDF3A6C121F2773BB3A347A7 /* counting_query_engine.cc in Sources */,
43124328
90BE848D96AE8CEF7035E1BA /* create_noop_connectivity_monitor.cc in Sources */,
43134329
43EDB01D1641D96C40DA1889 /* credentials_provider_test.cc in Sources */,
43144330
61976CE9C088131EC564A503 /* database_id_test.cc in Sources */,

Firestore/Example/Tests/Integration/FSTDatastoreTests.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "Firestore/core/src/firebase/firestore/local/local_store.h"
3333
#include "Firestore/core/src/firebase/firestore/local/memory_persistence.h"
3434
#include "Firestore/core/src/firebase/firestore/local/query_data.h"
35+
#include "Firestore/core/src/firebase/firestore/local/simple_query_engine.h"
3536
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
3637
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
3738
#include "Firestore/core/src/firebase/firestore/model/precondition.h"
@@ -57,6 +58,7 @@
5758
using firebase::firestore::local::MemoryPersistence;
5859
using firebase::firestore::local::Persistence;
5960
using firebase::firestore::local::QueryData;
61+
using firebase::firestore::local::SimpleQueryEngine;
6062
using firebase::firestore::model::BatchId;
6163
using firebase::firestore::model::DatabaseId;
6264
using firebase::firestore::model::DocumentKey;
@@ -213,6 +215,7 @@ @implementation FSTDatastoreTests {
213215
std::unique_ptr<Persistence> _persistence;
214216

215217
DatabaseInfo _databaseInfo;
218+
SimpleQueryEngine _queryEngine;
216219
std::shared_ptr<Datastore> _datastore;
217220
std::unique_ptr<RemoteStore> _remoteStore;
218221
}
@@ -236,7 +239,8 @@ - (void)setUp {
236239
std::make_shared<EmptyCredentialsProvider>());
237240

238241
_persistence = MemoryPersistence::WithEagerGarbageCollector();
239-
_localStore = absl::make_unique<LocalStore>(_persistence.get(), User::Unauthenticated());
242+
_localStore =
243+
absl::make_unique<LocalStore>(_persistence.get(), &_queryEngine, User::Unauthenticated());
240244

241245
_remoteStore = absl::make_unique<RemoteStore>(_localStore.get(), _datastore, _testWorkerQueue,
242246
[](OnlineState) {});

Firestore/Example/Tests/SpecTests/FSTSpecTests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ - (void)validateExpectedState:(nullable NSDictionary *)expectedState {
660660
// always the right value.
661661
expectedActiveTargets[targetID] =
662662
QueryData(std::move(query), targetID, 0, QueryPurpose::Listen,
663-
SnapshotVersion::None(), std::move(resumeToken));
663+
SnapshotVersion::None(), SnapshotVersion::None(), std::move(resumeToken));
664664
}];
665665
[self.driver setExpectedActiveTargets:expectedActiveTargets];
666666
}

Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "Firestore/core/src/firebase/firestore/core/sync_engine.h"
3636
#include "Firestore/core/src/firebase/firestore/local/local_store.h"
3737
#include "Firestore/core/src/firebase/firestore/local/persistence.h"
38+
#include "Firestore/core/src/firebase/firestore/local/simple_query_engine.h"
3839
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
3940
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
4041
#include "Firestore/core/src/firebase/firestore/objc/objc_compatibility.h"
@@ -69,6 +70,7 @@
6970
using firebase::firestore::local::LocalStore;
7071
using firebase::firestore::local::Persistence;
7172
using firebase::firestore::local::QueryData;
73+
using firebase::firestore::local::SimpleQueryEngine;
7274
using firebase::firestore::model::DatabaseId;
7375
using firebase::firestore::model::DocumentKey;
7476
using firebase::firestore::model::DocumentKeySet;
@@ -178,6 +180,9 @@ @implementation FSTSyncEngineTestDriver {
178180
std::vector<std::shared_ptr<EventListener<Empty>>> _snapshotsInSyncListeners;
179181
std::shared_ptr<MockDatastore> _datastore;
180182

183+
// TODO(index-free): Use IndexFreeQueryEngine
184+
SimpleQueryEngine _queryEngine;
185+
181186
int _snapshotsInSyncEvents;
182187
}
183188

@@ -203,7 +208,7 @@ - (instancetype)initWithPersistence:(std::unique_ptr<Persistence>)persistence
203208
// Set up the sync engine and various stores.
204209
_workerQueue = testutil::AsyncQueueForTesting();
205210
_persistence = std::move(persistence);
206-
_localStore = absl::make_unique<LocalStore>(_persistence.get(), initialUser);
211+
_localStore = absl::make_unique<LocalStore>(_persistence.get(), &_queryEngine, initialUser);
207212

208213
_datastore = std::make_shared<MockDatastore>(_databaseInfo, _workerQueue,
209214
std::make_shared<EmptyCredentialsProvider>());

Firestore/core/src/firebase/firestore/core/firestore_client.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "Firestore/core/src/firebase/firestore/local/leveldb_persistence.h"
2929
#include "Firestore/core/src/firebase/firestore/local/local_serializer.h"
3030
#include "Firestore/core/src/firebase/firestore/local/memory_persistence.h"
31+
#include "Firestore/core/src/firebase/firestore/local/query_result.h"
32+
#include "Firestore/core/src/firebase/firestore/local/simple_query_engine.h"
3133
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
3234
#include "Firestore/core/src/firebase/firestore/model/document_set.h"
3335
#include "Firestore/core/src/firebase/firestore/model/mutation.h"
@@ -62,6 +64,8 @@ using local::LocalSerializer;
6264
using local::LocalStore;
6365
using local::LruParams;
6466
using local::MemoryPersistence;
67+
using local::QueryResult;
68+
using local::SimpleQueryEngine;
6569
using model::DatabaseId;
6670
using model::Document;
6771
using model::DocumentKeySet;
@@ -181,7 +185,10 @@ void FirestoreClient::Initialize(const User& user, const Settings& settings) {
181185
persistence_ = MemoryPersistence::WithEagerGarbageCollector();
182186
}
183187

184-
local_store_ = absl::make_unique<LocalStore>(persistence_.get(), user);
188+
// TODO(index-free): Use IndexFreeQueryEngine
189+
query_engine_ = absl::make_unique<SimpleQueryEngine>();
190+
local_store_ = absl::make_unique<LocalStore>(persistence_.get(),
191+
query_engine_.get(), user);
185192

186193
auto datastore = std::make_shared<Datastore>(database_info_, worker_queue(),
187194
credentials_provider_);
@@ -378,11 +385,12 @@ void FirestoreClient::GetDocumentsFromLocalCache(
378385
auto shared_callback = absl::ShareUniquePtr(std::move(callback));
379386
auto shared_this = shared_from_this();
380387
worker_queue()->Enqueue([shared_this, query, shared_callback] {
381-
DocumentMap docs = shared_this->local_store_->ExecuteQuery(query.query());
388+
QueryResult query_result = shared_this->local_store_->ExecuteQuery(
389+
query.query(), /* use_previous_results= */ true);
382390

383-
View view(query.query(), DocumentKeySet{});
391+
View view(query.query(), query_result.remote_keys());
384392
ViewDocumentChanges view_doc_changes =
385-
view.ComputeDocumentChanges(docs.underlying_map());
393+
view.ComputeDocumentChanges(query_result.documents().underlying_map());
386394
ViewChange view_change = view.ApplyChanges(view_doc_changes);
387395
HARD_ASSERT(
388396
view_change.limbo_changes().empty(),

0 commit comments

Comments
 (0)