Skip to content

Commit 29f4b5d

Browse files
WIP
1 parent 91d317c commit 29f4b5d

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

firebase-firestore/src/test/java/com/google/firebase/firestore/local/CountingQueryEngine.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class CountingQueryEngine extends QueryEngine {
4141

4242
private final int[] mutationsReadByCollection = new int[] {0};
4343
private final int[] mutationsReadByKey = new int[] {0};
44+
private final int[] overlaysReadByCollection = new int[] {0};
45+
private final int[] overlaysReadByKey = new int[] {0};
4446
private final int[] documentsReadByCollection = new int[] {0};
4547
private final int[] documentsReadByKey = new int[] {0};
4648

@@ -51,6 +53,8 @@ class CountingQueryEngine extends QueryEngine {
5153
void resetCounts() {
5254
mutationsReadByCollection[0] = 0;
5355
mutationsReadByKey[0] = 0;
56+
overlaysReadByCollection[0] = 0;
57+
mutationsReadByKey[0] = 0;
5458
documentsReadByCollection[0] = 0;
5559
documentsReadByKey[0] = 0;
5660
}
@@ -74,11 +78,6 @@ public ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingQuery(
7478
return queryEngine.getDocumentsMatchingQuery(query, lastLimboFreeSnapshotVersion, remoteKeys);
7579
}
7680

77-
/** Returns the query engine that is used as the backing implementation. */
78-
QueryEngine getSubject() {
79-
return queryEngine;
80-
}
81-
8281
/**
8382
* Returns the number of documents returned by the RemoteDocumentCache's `getAll()` API (since the
8483
* last call to `resetCounts()`)

firebase-firestore/src/test/java/com/google/firebase/firestore/local/IndexingEnabledSQLiteLocalStoreTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static com.google.firebase.firestore.testutil.TestUtil.filter;
2323
import static com.google.firebase.firestore.testutil.TestUtil.map;
2424
import static com.google.firebase.firestore.testutil.TestUtil.query;
25+
import static com.google.firebase.firestore.testutil.TestUtil.setMutation;
2526
import static com.google.firebase.firestore.testutil.TestUtil.updateRemoteEvent;
2627
import static java.util.Collections.emptyList;
2728
import static java.util.Collections.singletonList;
@@ -87,7 +88,7 @@ public void testUsesIndexes() {
8788
}
8889

8990
@Test
90-
public void testUsesPartialIndexesWhenAvailable() {
91+
public void testUsesPartialIndexedRemoteDocumentsWhenAvailable() {
9192
FieldIndex index = fieldIndex("coll", 0, FieldIndex.INITIAL_STATE, "matches", Kind.ASCENDING);
9293
configureFieldIndexes(singletonList(index));
9394

@@ -104,6 +105,22 @@ public void testUsesPartialIndexesWhenAvailable() {
104105
assertQueryReturned("coll/a", "coll/b");
105106
}
106107

108+
@Test
109+
public void testUsesPartialIndexedOverlaysWhenAvailable() {
110+
FieldIndex index = fieldIndex("coll", 0, FieldIndex.INITIAL_STATE, "matches", Kind.ASCENDING);
111+
configureFieldIndexes(singletonList(index));
112+
113+
writeMutation(setMutation("coll/a", map("matches", true)));
114+
backfillIndexes();
115+
116+
writeMutation(setMutation("coll/b", map("matches", true)));
117+
118+
Query query = query("coll").filter(filter("matches", "==", true));
119+
executeQuery(query);
120+
assertMutationsRead(/* byKey= */ 1, /* byCollection= */ 1);
121+
assertQueryReturned("coll/a", "coll/b");
122+
}
123+
107124
@Test
108125
public void testDeletedDocumentRemovesIndex() {
109126
FieldIndex index = fieldIndex("coll", 0, FieldIndex.INITIAL_STATE, "matches", Kind.ASCENDING);

firebase-firestore/src/test/java/com/google/firebase/firestore/local/LocalStoreTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void tearDown() {
136136
localStorePersistence.shutdown();
137137
}
138138

139-
private void writeMutation(Mutation mutation) {
139+
protected void writeMutation(Mutation mutation) {
140140
writeMutations(asList(mutation));
141141
}
142142

@@ -327,7 +327,7 @@ private void assertHasNamedQuery(NamedQuery expectedNamedQuery) {
327327
* Asserts the expected numbers of mutations read by the MutationQueue since the last call to
328328
* `resetPersistenceStats()`.
329329
*/
330-
private void assertMutationsRead(int byKey, int byCollection) {
330+
protected void assertMutationsRead(int byKey, int byCollection) {
331331
assertEquals(
332332
"Mutations read (by collection)", byCollection, queryEngine.getMutationsReadByCollection());
333333
assertEquals("Mutations read (by key)", byKey, queryEngine.getMutationsReadByKey());

0 commit comments

Comments
 (0)