Skip to content

Commit 6004cdf

Browse files
committed
Rename filterDocumentType to tryFilterDocumentType to emphasize that the filtering is a "best effort" and not guaranteed.
1 parent cbdfd5f commit 6004cdf

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private Map<DocumentKey, MutableDocument> getAll(
209209
List<ResourcePath> collections,
210210
IndexOffset offset,
211211
int count,
212-
@Nullable DocumentType filterDocumentType,
212+
@Nullable DocumentType tryFilterDocumentType,
213213
@Nullable Function<MutableDocument, Boolean> filter,
214214
@Nullable QueryContext context) {
215215
Timestamp readTime = offset.getReadTime().getTimestamp();
@@ -220,7 +220,7 @@ private Map<DocumentKey, MutableDocument> getAll(
220220
"SELECT contents, read_time_seconds, read_time_nanos, path "
221221
+ "FROM remote_documents "
222222
+ "WHERE path >= ? AND path < ? AND path_length = ? "
223-
+ (filterDocumentType == null
223+
+ (tryFilterDocumentType == null
224224
? ""
225225
: " AND (document_type IS NULL OR document_type = ?) ")
226226
+ "AND (read_time_seconds > ? OR ( "
@@ -232,15 +232,16 @@ private Map<DocumentKey, MutableDocument> getAll(
232232

233233
Object[] bindVars =
234234
new Object
235-
[(BINDS_PER_STATEMENT + (filterDocumentType != null ? 1 : 0)) * collections.size() + 1];
235+
[(BINDS_PER_STATEMENT + (tryFilterDocumentType != null ? 1 : 0)) * collections.size()
236+
+ 1];
236237
int i = 0;
237238
for (ResourcePath collection : collections) {
238239
String prefixPath = EncodedPath.encode(collection);
239240
bindVars[i++] = prefixPath;
240241
bindVars[i++] = EncodedPath.prefixSuccessor(prefixPath);
241242
bindVars[i++] = collection.length() + 1;
242-
if (filterDocumentType != null) {
243-
bindVars[i++] = filterDocumentType.dbValue;
243+
if (tryFilterDocumentType != null) {
244+
bindVars[i++] = tryFilterDocumentType.dbValue;
244245
}
245246
bindVars[i++] = readTime.getSeconds();
246247
bindVars[i++] = readTime.getSeconds();
@@ -272,7 +273,7 @@ private Map<DocumentKey, MutableDocument> getAll(
272273
int count,
273274
@Nullable Function<MutableDocument, Boolean> filter) {
274275
return getAll(
275-
collections, offset, count, /*filterDocumentType*/ null, filter, /*context*/ null);
276+
collections, offset, count, /*tryFilterDocumentType*/ null, filter, /*context*/ null);
276277
}
277278

278279
private void processRowInBackground(
@@ -315,7 +316,7 @@ public Map<DocumentKey, MutableDocument> getDocumentsMatchingQuery(
315316
Collections.singletonList(query.getPath()),
316317
offset,
317318
Integer.MAX_VALUE,
318-
// Specify filterDocumentType=FOUND_DOCUMENT to getAll() as an optimization, because
319+
// Specify tryFilterDocumentType=FOUND_DOCUMENT to getAll() as an optimization, because
319320
// query.matches(doc) will return false for all non-"found" document types anyways.
320321
// See https://github.com/firebase/firebase-android-sdk/issues/7295
321322
DocumentType.FOUND_DOCUMENT,

0 commit comments

Comments
 (0)