Skip to content

Commit bbb186b

Browse files
Cleanup
1 parent d775f44 commit bbb186b

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ public interface IndexManager {
8282
@Nullable
8383
String getNextCollectionGroupToUpdate(Timestamp lastUpdateTime);
8484

85-
/**
86-
* Updates the index entries for the provided documents and corresponding field indexes. Updates
87-
* the field indexes in persistence with the latest read time that was processed.
88-
*/
85+
/** Updates the index entries for the provided documents and corresponding field indexes. */
8986
void updateIndexEntries(Collection<Document> documents);
9087
}

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

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -329,33 +329,36 @@ private FieldIndex getPostUpdateIndex(FieldIndex baseIndex, SnapshotVersion newR
329329

330330
/** Creates a list of index entries for the given document. */
331331
private List<IndexEntry> computeEntries(Document document, FieldIndex fieldIndex) {
332-
List<IndexEntry> indexEntries = new ArrayList<>();
333332

334333
@Nullable byte[] directionalValue = encodeDirectionalElements(fieldIndex, document);
335-
if (directionalValue != null) {
336-
@Nullable FieldIndex.Segment arraySegment = fieldIndex.getArraySegment();
337-
if (arraySegment != null) {
338-
Value value = document.getField(arraySegment.getFieldPath());
339-
if (isArray(value)) {
340-
for (Value arrayValue : value.getArrayValue().getValuesList()) {
341-
indexEntries.add(
342-
IndexEntry.create(
343-
fieldIndex.getIndexId(),
344-
document.getKey().getName(),
345-
document.hasLocalMutations() ? user.getUid() : null,
346-
directionalValue,
347-
encodeSingleElement(arrayValue)));
348-
}
334+
if (directionalValue == null) {
335+
return Collections.emptyList();
336+
}
337+
338+
List<IndexEntry> indexEntries = new ArrayList<>();
339+
340+
@Nullable FieldIndex.Segment arraySegment = fieldIndex.getArraySegment();
341+
if (arraySegment != null) {
342+
Value value = document.getField(arraySegment.getFieldPath());
343+
if (isArray(value)) {
344+
for (Value arrayValue : value.getArrayValue().getValuesList()) {
345+
indexEntries.add(
346+
IndexEntry.create(
347+
fieldIndex.getIndexId(),
348+
document.getKey().getName(),
349+
document.hasLocalMutations() ? user.getUid() : null,
350+
directionalValue,
351+
encodeSingleElement(arrayValue)));
349352
}
350-
} else {
351-
indexEntries.add(
352-
IndexEntry.create(
353-
fieldIndex.getIndexId(),
354-
document.getKey().getName(),
355-
document.hasLocalMutations() ? user.getUid() : null,
356-
directionalValue,
357-
/* arrayValue= */ null));
358353
}
354+
} else {
355+
indexEntries.add(
356+
IndexEntry.create(
357+
fieldIndex.getIndexId(),
358+
document.getKey().getName(),
359+
document.hasLocalMutations() ? user.getUid() : null,
360+
directionalValue,
361+
/* arrayValue= */ null));
359362
}
360363

361364
return indexEntries;

0 commit comments

Comments
 (0)