Skip to content

Commit b41687f

Browse files
author
Michael Lehenbauer
committed
Tweaks from iOS code review.
1 parent 3fc8914 commit b41687f

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ public Query endAt(Bound bound) {
258258
}
259259

260260
/**
261-
* Helper to convert a Collection Group query into a collection query at a specific path. This is
262-
* used when executing Collection Group queries, since we have to split the query into a set of
263-
* Collection queries at multiple paths.
261+
* Helper to convert a collection group query into a collection query at a specific path. This is
262+
* used when executing collection group queries, since we have to split the query into a set of
263+
* collection queries at multiple paths.
264264
*/
265265
public Query asCollectionQueryAtPath(ResourcePath path) {
266266
return new Query(

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void runMigrations(int fromVersion, int toVersion) {
115115
}
116116

117117
if (fromVersion < 8 && toVersion >= 8) {
118-
createV8CollectionParentIndex();
118+
createV8CollectionParentsIndex();
119119
}
120120

121121
/*
@@ -372,10 +372,14 @@ private void ensureSequenceNumbers() {
372372
});
373373
}
374374

375-
private void createV8CollectionParentIndex() {
375+
private void createV8CollectionParentsIndex() {
376376
ifTablesDontExist(
377377
new String[] {"collection_parents"},
378378
() -> {
379+
// A table storing associations between a Collection ID (e.g. 'messages') to a parent path
380+
// (e.g. '/chats/123') that contains it as a (sub)collection. This is used to efficiently
381+
// find all collections to query when performing a Collection Group query. Note that the
382+
// parent path will be an empty path in the case of root-level collections.
379383
db.execSQL(
380384
"CREATE TABLE collection_parents ("
381385
+ "collection_id TEXT, "
@@ -390,10 +394,10 @@ private void createV8CollectionParentIndex() {
390394
db.compileStatement(
391395
"INSERT OR REPLACE INTO collection_parents (collection_id, parent) VALUES (?, ?)");
392396
Consumer<ResourcePath> addEntry =
393-
path -> {
394-
if (cache.add(path)) {
395-
String collectionId = path.getLastSegment();
396-
ResourcePath parentPath = path.popLast();
397+
collectionPath -> {
398+
if (cache.add(collectionPath)) {
399+
String collectionId = collectionPath.getLastSegment();
400+
ResourcePath parentPath = collectionPath.popLast();
397401
addIndexEntry.clearBindings();
398402
addIndexEntry.bindString(1, collectionId);
399403
addIndexEntry.bindString(2, EncodedPath.encode(parentPath));

0 commit comments

Comments
 (0)