Skip to content

Commit 636d9c9

Browse files
Merge
2 parents 8fd0a71 + 7d86138 commit 636d9c9

25 files changed

+528
-471
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/remote/RemoteStoreTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import com.google.firebase.database.collection.ImmutableSortedSet;
2222
import com.google.firebase.firestore.auth.User;
2323
import com.google.firebase.firestore.core.OnlineState;
24-
import com.google.firebase.firestore.local.DefaultQueryEngine;
2524
import com.google.firebase.firestore.local.IndexBackfiller;
2625
import com.google.firebase.firestore.local.LocalStore;
2726
import com.google.firebase.firestore.local.MemoryPersistence;
2827
import com.google.firebase.firestore.local.Persistence;
28+
import com.google.firebase.firestore.local.QueryEngine;
2929
import com.google.firebase.firestore.model.DocumentKey;
3030
import com.google.firebase.firestore.model.mutation.MutationBatchResult;
3131
import com.google.firebase.firestore.testutil.IntegrationTestUtil;
@@ -76,7 +76,7 @@ public ImmutableSortedSet<DocumentKey> getRemoteKeysForTarget(int targetId) {
7676
};
7777

7878
FakeConnectivityMonitor connectivityMonitor = new FakeConnectivityMonitor();
79-
DefaultQueryEngine queryEngine = new DefaultQueryEngine();
79+
QueryEngine queryEngine = new QueryEngine();
8080
Persistence persistence = MemoryPersistence.createEagerGcMemoryPersistence();
8181
persistence.start();
8282
IndexBackfiller indexBackfiller = new IndexBackfiller(persistence, new AsyncQueue());

firebase-firestore/src/main/java/com/google/firebase/firestore/core/MemoryComponentProvider.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
import androidx.annotation.Nullable;
1818
import com.google.firebase.database.collection.ImmutableSortedSet;
19-
import com.google.firebase.firestore.local.DefaultQueryEngine;
2019
import com.google.firebase.firestore.local.IndexBackfiller;
2120
import com.google.firebase.firestore.local.LocalStore;
2221
import com.google.firebase.firestore.local.MemoryPersistence;
2322
import com.google.firebase.firestore.local.Persistence;
23+
import com.google.firebase.firestore.local.QueryEngine;
2424
import com.google.firebase.firestore.local.Scheduler;
2525
import com.google.firebase.firestore.model.DocumentKey;
2626
import com.google.firebase.firestore.model.mutation.MutationBatchResult;
@@ -54,10 +54,7 @@ protected EventManager createEventManager(Configuration configuration) {
5454
@Override
5555
protected LocalStore createLocalStore(Configuration configuration) {
5656
return new LocalStore(
57-
getPersistence(),
58-
getIndexBackfiller(),
59-
new DefaultQueryEngine(),
60-
configuration.getInitialUser());
57+
getPersistence(), getIndexBackfiller(), new QueryEngine(), configuration.getInitialUser());
6158
}
6259

6360
@Override

firebase-firestore/src/main/java/com/google/firebase/firestore/local/DefaultQueryEngine.java

Lines changed: 0 additions & 175 deletions
This file was deleted.

firebase-firestore/src/main/java/com/google/firebase/firestore/local/IndexedQueryEngine.java

Lines changed: 0 additions & 103 deletions
This file was deleted.

firebase-firestore/src/main/java/com/google/firebase/firestore/local/LocalStore.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ public LocalStore(
169169
new LocalDocumentsView(remoteDocuments, mutationQueue, documentOverlayCache, indexManager);
170170
this.queryEngine = queryEngine;
171171
this.indexBackfiller = indexBackfiller;
172-
queryEngine.setLocalDocumentsView(localDocuments);
173-
queryEngine.setIndexManager(indexManager);
172+
queryEngine.initialize(localDocuments, indexManager);
174173

175174
localViewReferences = new ReferenceSet();
176175
persistence.getReferenceDelegate().setInMemoryPins(localViewReferences);
@@ -215,8 +214,7 @@ public ImmutableSortedMap<DocumentKey, Document> handleUserChange(User user) {
215214
// Recreate our LocalDocumentsView using the new MutationQueue.
216215
localDocuments =
217216
new LocalDocumentsView(remoteDocuments, mutationQueue, documentOverlayCache, indexManager);
218-
queryEngine.setLocalDocumentsView(localDocuments);
219-
queryEngine.setIndexManager(indexManager);
217+
queryEngine.initialize(localDocuments, indexManager);
220218

221219
// TODO(indexing): Add spec tests that test these components change after a user change
222220
remoteDocuments.setIndexManager(indexManager);
@@ -496,6 +494,7 @@ private DocumentChangeResult populateDocumentChanges(
496494
@Nullable Map<DocumentKey, SnapshotVersion> documentVersions,
497495
SnapshotVersion globalVersion) {
498496
Map<DocumentKey, MutableDocument> changedDocs = new HashMap<>();
497+
List<DocumentKey> removedDocs = new ArrayList<>();
499498
Set<DocumentKey> conditionChanged = new HashSet<>();
500499

501500
// Each loop iteration only affects its "own" doc, so it's safe to get all the remote
@@ -519,7 +518,7 @@ private DocumentChangeResult populateDocumentChanges(
519518
if (doc.isNoDocument() && doc.getVersion().equals(SnapshotVersion.NONE)) {
520519
// NoDocuments with SnapshotVersion.NONE are used in manufactured events. We remove
521520
// these documents from cache since we lost access.
522-
remoteDocuments.remove(doc.getKey());
521+
removedDocs.add(doc.getKey());
523522
changedDocs.put(key, doc);
524523
} else if (!existingDoc.isValidDocument()
525524
|| doc.getVersion().compareTo(existingDoc.getVersion()) > 0
@@ -539,6 +538,7 @@ private DocumentChangeResult populateDocumentChanges(
539538
doc.getVersion());
540539
}
541540
}
541+
remoteDocuments.removeAll(removedDocs);
542542
return new DocumentChangeResult(changedDocs, conditionChanged);
543543
}
544544

@@ -849,7 +849,7 @@ public QueryResult executeQuery(Query query, boolean usePreviousResults) {
849849
queryEngine.getDocumentsMatchingQuery(
850850
query,
851851
usePreviousResults ? lastLimboFreeSnapshotVersion : SnapshotVersion.NONE,
852-
usePreviousResults ? remoteKeys : DocumentKey.emptyKeySet());
852+
remoteKeys);
853853
return new QueryResult(documents, remoteKeys);
854854
}
855855

0 commit comments

Comments
 (0)