Skip to content

Commit c010b5e

Browse files
committed
Simplify
1 parent 1cb07fd commit c010b5e

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public int getDocumentReadCount() {
2323
return documentReadCount;
2424
}
2525

26-
public void incrementDocumentReadCount() {
27-
documentReadCount++;
26+
public void incrementDocumentReadCount(int cnt) {
27+
documentReadCount += cnt;
2828
}
2929
}

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

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public Map<DocumentKey, MutableDocument> getAll(
159159
if (collections.isEmpty()) {
160160
return Collections.emptyMap();
161161
} else if (BINDS_PER_STATEMENT * collections.size() < SQLitePersistence.MAX_ARGS) {
162-
return getAll(collections, offset, limit, /*filter*/ null);
162+
return getAll(collections, offset, limit, /*filter*/ null, /*context*/ null);
163163
} else {
164164
// We need to fan out our collection scan since SQLite only supports 999 binds per statement.
165165
Map<DocumentKey, MutableDocument> results = new HashMap<>();
@@ -170,7 +170,8 @@ public Map<DocumentKey, MutableDocument> getAll(
170170
collections.subList(i, Math.min(collections.size(), i + pageSize)),
171171
offset,
172172
limit,
173-
/*filter*/ null));
173+
/*filter*/ null,
174+
/*context*/ null));
174175
}
175176
return firstNEntries(results, limit, IndexOffset.DOCUMENT_COMPARATOR);
176177
}
@@ -218,27 +219,16 @@ private Map<DocumentKey, MutableDocument> getAll(
218219

219220
BackgroundQueue backgroundQueue = new BackgroundQueue();
220221
Map<DocumentKey, MutableDocument> results = new HashMap<>();
221-
db.query(sql.toString())
222+
int cnt = db.query(sql.toString())
222223
.binding(bindVars)
223-
.forEach(
224-
row -> {
225-
processRowInBackground(backgroundQueue, results, row, filter);
226-
if (context != null) {
227-
context.incrementDocumentReadCount();
228-
}
229-
});
224+
.forEach(row -> processRowInBackground(backgroundQueue, results, row, filter));
225+
if (context != null) {
226+
context.incrementDocumentReadCount(cnt);
227+
}
230228
backgroundQueue.drain();
231229
return results;
232230
}
233231

234-
private Map<DocumentKey, MutableDocument> getAll(
235-
List<ResourcePath> collections,
236-
IndexOffset offset,
237-
int count,
238-
@Nullable Predicate<MutableDocument> filter) {
239-
return getAll(collections, offset, count, filter, /*context*/ null);
240-
}
241-
242232
private void processRowInBackground(
243233
BackgroundQueue backgroundQueue,
244234
Map<DocumentKey, MutableDocument> results,

0 commit comments

Comments
 (0)