Skip to content

Commit 4e566d9

Browse files
authored
Change comments and test instances in QueryEngine (#3818)
1 parent bd94e28 commit 4e566d9

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,9 @@
5454
* least once and allow the query engine to only read documents that previously matched a query plus
5555
* any documents that were edited after the query was last listened to.
5656
*
57-
* <p>There are some cases where this specific optimization is not guaranteed to produce the same
58-
* results as full collection scans. In these cases, query processing falls back to full scans.
59-
* These cases are:
60-
*
61-
* <ol>
62-
* <li>Limit queries where a document that matched the query previously no longer matches the
63-
* query.
64-
* <li>Limit queries where a document edit may cause the document to sort below another document
65-
* that is in the local cache.
66-
* <li>Queries that have never been CURRENT or free of limbo documents.
67-
* </ol>
57+
* <p>For queries that have never been CURRENT or free of limbo documents, this specific
58+
* optimization is not guaranteed to produce the same results as full collection scans. So in these
59+
* cases, query processing falls back to full scans.
6860
*/
6961
public class QueryEngine {
7062
private static final String LOG_TAG = "QueryEngine";

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public abstract class QueryEngineTestCase {
6767
doc("coll/a", 1, map("matches", true, "order", 1));
6868
private static final MutableDocument NON_MATCHING_DOC_A =
6969
doc("coll/a", 1, map("matches", false, "order", 1));
70+
private static final MutableDocument PENDING_MATCHING_DOC_A =
71+
doc("coll/a", 1, map("matches", true, "order", 1)).setHasLocalMutations();
72+
private static final MutableDocument PENDING_NON_MATCHING_DOC_A =
73+
doc("coll/a", 1, map("matches", false, "order", 1)).setHasLocalMutations();
7074
private static final MutableDocument UPDATED_DOC_A =
7175
doc("coll/a", 11, map("matches", true, "order", 1));
7276
private static final MutableDocument MATCHING_DOC_B =
@@ -230,7 +234,7 @@ public void filtersNonMatchingInitialResults() throws Exception {
230234
persistQueryMapping(MATCHING_DOC_A.getKey(), MATCHING_DOC_B.getKey());
231235

232236
// Add a mutated document that is not yet part of query's set of remote keys.
233-
addDocumentWithEventVersion(version(1), NON_MATCHING_DOC_A);
237+
addDocumentWithEventVersion(version(1), PENDING_NON_MATCHING_DOC_A);
234238

235239
DocumentSet docs =
236240
expectOptimizedCollectionScan(() -> runQuery(query, LAST_LIMBO_FREE_SNAPSHOT));
@@ -314,9 +318,9 @@ public void doesNotUseInitialResultsForLimitQueryWhenLastDocumentHasPendingWrite
314318

315319
// Add a query mapping for a document that matches, but that sorts below another document due to
316320
// a pending write.
317-
addDocumentWithEventVersion(version(1), MATCHING_DOC_A);
321+
addDocumentWithEventVersion(version(1), PENDING_MATCHING_DOC_A);
318322
addMutation(DOC_A_EMPTY_PATCH);
319-
persistQueryMapping(MATCHING_DOC_A.getKey());
323+
persistQueryMapping(PENDING_MATCHING_DOC_A.getKey());
320324

321325
addDocument(MATCHING_DOC_B);
322326

@@ -335,9 +339,9 @@ public void doesNotUseInitialResultsForLimitToLastQueryWhenLastDocumentHasPendin
335339

336340
// Add a query mapping for a document that matches, but that sorts below another document due to
337341
// a pending write.
338-
addDocumentWithEventVersion(version(1), MATCHING_DOC_A);
342+
addDocumentWithEventVersion(version(1), PENDING_MATCHING_DOC_A);
339343
addMutation(DOC_A_EMPTY_PATCH);
340-
persistQueryMapping(MATCHING_DOC_A.getKey());
344+
persistQueryMapping(PENDING_MATCHING_DOC_A.getKey());
341345

342346
addDocument(MATCHING_DOC_B);
343347

0 commit comments

Comments
 (0)