Skip to content

Commit 7f0bff1

Browse files
Returns the minimum index type from all targets (#3656)
We need to return the least restrictive index type and not the first one we find
1 parent 5600426 commit 7f0bff1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*/
3434
public interface IndexManager {
3535
/** Represents the index state as it relates to a particular target. */
36-
public enum IndexType {
36+
enum IndexType {
3737
/** Indicates that no index could be found for serving the target. */
3838
NONE,
3939
/**

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,19 @@ public IndexOffset getMinOffset(String collectionGroup) {
313313

314314
@Override
315315
public IndexType getIndexType(Target target) {
316+
IndexType result = IndexType.FULL;
316317
for (Target subTarget : getSubTargets(target)) {
317318
FieldIndex index = getFieldIndex(subTarget);
318319
if (index == null) {
319-
return IndexType.NONE;
320+
result = IndexType.NONE;
321+
break;
320322
}
321323

322324
if (index.getSegments().size() < subTarget.getSegmentCount()) {
323-
return IndexType.PARTIAL;
325+
result = IndexType.PARTIAL;
324326
}
325327
}
326-
return IndexType.FULL;
328+
return result;
327329
}
328330

329331
@Override

0 commit comments

Comments
 (0)