@@ -329,33 +329,36 @@ private FieldIndex getPostUpdateIndex(FieldIndex baseIndex, SnapshotVersion newR
329
329
330
330
/** Creates a list of index entries for the given document. */
331
331
private List <IndexEntry > computeEntries (Document document , FieldIndex fieldIndex ) {
332
- List <IndexEntry > indexEntries = new ArrayList <>();
333
332
334
333
@ 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 )));
349
352
}
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 ));
358
353
}
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 ));
359
362
}
360
363
361
364
return indexEntries ;
0 commit comments