@@ -124,7 +124,8 @@ public SnapshotVersion decodeVersion(com.google.protobuf.Timestamp proto) {
124
124
// Names and Keys
125
125
126
126
/**
127
- * Encodes the given document key as a fully qualified name. This includes the databaseId from the
127
+ * Encodes the given document key as a fully qualified name. This includes the
128
+ * databaseId from the
128
129
* constructor and the key path.
129
130
*/
130
131
public String encodeKey (DocumentKey key ) {
@@ -149,8 +150,10 @@ private String encodeQueryPath(ResourcePath path) {
149
150
private ResourcePath decodeQueryPath (String name ) {
150
151
ResourcePath resource = decodeResourceName (name );
151
152
if (resource .length () == 4 ) {
152
- // In v1beta1 queries for collections at the root did not have a trailing "/documents". In v1
153
- // all resource paths contain "/documents". Preserve the ability to read the v1 form for
153
+ // In v1beta1 queries for collections at the root did not have a trailing
154
+ // "/documents". In v1
155
+ // all resource paths contain "/documents". Preserve the ability to read the v1
156
+ // form for
154
157
// compatibility with queries persisted in the local query cache.
155
158
return ResourcePath .EMPTY ;
156
159
} else {
@@ -167,8 +170,10 @@ private String encodeResourceName(DatabaseId databaseId, ResourcePath path) {
167
170
}
168
171
169
172
/**
170
- * Decodes a fully qualified resource name into a resource path and validates that there is a
171
- * project and database encoded in the path. There are no guarantees that a local path is also
173
+ * Decodes a fully qualified resource name into a resource path and validates
174
+ * that there is a
175
+ * project and database encoded in the path. There are no guarantees that a
176
+ * local path is also
172
177
* encoded in this resource name.
173
178
*/
174
179
private ResourcePath decodeResourceName (String encoded ) {
@@ -178,15 +183,19 @@ private ResourcePath decodeResourceName(String encoded) {
178
183
return resource ;
179
184
}
180
185
181
- /** Creates the prefix for a fully qualified resource path, without a local path on the end. */
186
+ /**
187
+ * Creates the prefix for a fully qualified resource path, without a local path
188
+ * on the end.
189
+ */
182
190
private static ResourcePath encodedDatabaseId (DatabaseId databaseId ) {
183
191
return ResourcePath .fromSegments (
184
192
Arrays .asList (
185
193
"projects" , databaseId .getProjectId (), "databases" , databaseId .getDatabaseId ()));
186
194
}
187
195
188
196
/**
189
- * Decodes a fully qualified resource name into a resource path and validates that there is a
197
+ * Decodes a fully qualified resource name into a resource path and validates
198
+ * that there is a
190
199
* project and database encoded in the path along with a local path.
191
200
*/
192
201
private static ResourcePath extractLocalPathFromResourceName (ResourcePath resourceName ) {
@@ -197,7 +206,10 @@ private static ResourcePath extractLocalPathFromResourceName(ResourcePath resour
197
206
return resourceName .popFirst (5 );
198
207
}
199
208
200
- /** Validates that a path has a prefix that looks like a valid encoded databaseId. */
209
+ /**
210
+ * Validates that a path has a prefix that looks like a valid encoded
211
+ * databaseId.
212
+ */
201
213
private static boolean isValidResourceName (ResourcePath path ) {
202
214
// Resource names have at least 4 components (project ID, database ID)
203
215
// and commonly the (root) resource type, e.g. documents
@@ -219,8 +231,7 @@ public String databaseName() {
219
231
// Documents
220
232
221
233
public com .google .firestore .v1 .Document encodeDocument (DocumentKey key , ObjectValue value ) {
222
- com .google .firestore .v1 .Document .Builder builder =
223
- com .google .firestore .v1 .Document .newBuilder ();
234
+ com .google .firestore .v1 .Document .Builder builder = com .google .firestore .v1 .Document .newBuilder ();
224
235
builder .setName (encodeKey (key ));
225
236
builder .putAllFields (value .getFieldsMap ());
226
237
return builder .build ();
@@ -289,10 +300,9 @@ public com.google.firestore.v1.Write encodeMutation(Mutation mutation) {
289
300
}
290
301
291
302
public Mutation decodeMutation (com .google .firestore .v1 .Write mutation ) {
292
- Precondition precondition =
293
- mutation .hasCurrentDocument ()
294
- ? decodePrecondition (mutation .getCurrentDocument ())
295
- : Precondition .NONE ;
303
+ Precondition precondition = mutation .hasCurrentDocument ()
304
+ ? decodePrecondition (mutation .getCurrentDocument ())
305
+ : Precondition .NONE ;
296
306
297
307
List <FieldTransform > fieldTransforms = new ArrayList <>();
298
308
for (DocumentTransform .FieldTransform fieldTransform : mutation .getUpdateTransformsList ()) {
@@ -329,8 +339,7 @@ public Mutation decodeMutation(com.google.firestore.v1.Write mutation) {
329
339
330
340
private com .google .firestore .v1 .Precondition encodePrecondition (Precondition precondition ) {
331
341
hardAssert (!precondition .isNone (), "Can't serialize an empty precondition" );
332
- com .google .firestore .v1 .Precondition .Builder builder =
333
- com .google .firestore .v1 .Precondition .newBuilder ();
342
+ com .google .firestore .v1 .Precondition .Builder builder = com .google .firestore .v1 .Precondition .newBuilder ();
334
343
if (precondition .getUpdateTime () != null ) {
335
344
return builder .setUpdateTime (encodeVersion (precondition .getUpdateTime ())).build ();
336
345
} else if (precondition .getExists () != null ) {
@@ -390,8 +399,7 @@ private DocumentTransform.FieldTransform encodeFieldTransform(FieldTransform fie
390
399
.setRemoveAllFromArray (ArrayValue .newBuilder ().addAllValues (remove .getElements ()))
391
400
.build ();
392
401
} else if (transform instanceof NumericIncrementTransformOperation ) {
393
- NumericIncrementTransformOperation incrementOperation =
394
- (NumericIncrementTransformOperation ) transform ;
402
+ NumericIncrementTransformOperation incrementOperation = (NumericIncrementTransformOperation ) transform ;
395
403
return DocumentTransform .FieldTransform .newBuilder ()
396
404
.setFieldPath (fieldTransform .getFieldPath ().canonicalString ())
397
405
.setIncrement (incrementOperation .getOperand ())
@@ -405,8 +413,7 @@ private FieldTransform decodeFieldTransform(DocumentTransform.FieldTransform fie
405
413
switch (fieldTransform .getTransformTypeCase ()) {
406
414
case SET_TO_SERVER_VALUE :
407
415
hardAssert (
408
- fieldTransform .getSetToServerValue ()
409
- == DocumentTransform .FieldTransform .ServerValue .REQUEST_TIME ,
416
+ fieldTransform .getSetToServerValue () == DocumentTransform .FieldTransform .ServerValue .REQUEST_TIME ,
410
417
"Unknown transform setToServerValue: %s" ,
411
418
fieldTransform .getSetToServerValue ());
412
419
return new FieldTransform (
@@ -433,9 +440,12 @@ private FieldTransform decodeFieldTransform(DocumentTransform.FieldTransform fie
433
440
434
441
public MutationResult decodeMutationResult (
435
442
com .google .firestore .v1 .WriteResult proto , SnapshotVersion commitVersion ) {
436
- // NOTE: Deletes don't have an updateTime but the commit timestamp from the containing
437
- // CommitResponse or WriteResponse indicates essentially that the delete happened no later than
438
- // that. For our purposes we don't care exactly when the delete happened so long as we can tell
443
+ // NOTE: Deletes don't have an updateTime but the commit timestamp from the
444
+ // containing
445
+ // CommitResponse or WriteResponse indicates essentially that the delete
446
+ // happened no later than
447
+ // that. For our purposes we don't care exactly when the delete happened so long
448
+ // as we can tell
439
449
// when an update on the watch stream is at or later than that change.
440
450
SnapshotVersion version = decodeVersion (proto .getUpdateTime ());
441
451
if (SnapshotVersion .NONE .equals (version )) {
@@ -454,7 +464,8 @@ public MutationResult decodeMutationResult(
454
464
455
465
@ Nullable
456
466
public Map <String , String > encodeListenRequestLabels (TargetData targetData ) {
457
- @ Nullable String value = encodeLabel (targetData .getPurpose ());
467
+ @ Nullable
468
+ String value = encodeLabel (targetData .getPurpose ());
458
469
if (value == null ) {
459
470
return null ;
460
471
}
@@ -471,6 +482,8 @@ private String encodeLabel(QueryPurpose purpose) {
471
482
return null ;
472
483
case EXISTENCE_FILTER_MISMATCH :
473
484
return "existence-filter-mismatch" ;
485
+ case EXISTENCE_FILTER_MISMATCH_BLOOM :
486
+ return "existence-filter-mismatch-bloom" ;
474
487
case LIMBO_RESOLUTION :
475
488
return "limbo-document" ;
476
489
default :
@@ -492,7 +505,8 @@ public Target encodeTarget(TargetData targetData) {
492
505
493
506
if (targetData .getResumeToken ().isEmpty ()
494
507
&& targetData .getSnapshotVersion ().compareTo (SnapshotVersion .NONE ) > 0 ) {
495
- // TODO(wuandy): Consider removing above check because it is most likely true. Right now, many
508
+ // TODO(wuandy): Consider removing above check because it is most likely true.
509
+ // Right now, many
496
510
// tests depend on this behaviour though (leaving min() out of serialization).
497
511
builder .setReadTime (encodeTimestamp (targetData .getSnapshotVersion ().getTimestamp ()));
498
512
} else {
@@ -649,11 +663,11 @@ private StructuredQuery.Filter encodeFilters(List<Filter> filters) {
649
663
private List <Filter > decodeFilters (StructuredQuery .Filter proto ) {
650
664
Filter result = decodeFilter (proto );
651
665
652
- // Instead of a singletonList containing AND(F1, F2, ...), we can return a list containing F1,
666
+ // Instead of a singletonList containing AND(F1, F2, ...), we can return a list
667
+ // containing F1,
653
668
// F2, ... to stay consistent with the older SDK versions.
654
669
if (result instanceof com .google .firebase .firestore .core .CompositeFilter ) {
655
- com .google .firebase .firestore .core .CompositeFilter compositeFilter =
656
- (com .google .firebase .firestore .core .CompositeFilter ) result ;
670
+ com .google .firebase .firestore .core .CompositeFilter compositeFilter = (com .google .firebase .firestore .core .CompositeFilter ) result ;
657
671
if (compositeFilter .isFlatConjunction ()) {
658
672
return compositeFilter .getFilters ();
659
673
}
@@ -911,9 +925,8 @@ public WatchChange decodeWatchChange(ListenResponse protoChange) {
911
925
default :
912
926
throw new IllegalArgumentException ("Unknown target change type" );
913
927
}
914
- watchChange =
915
- new WatchTargetChange (
916
- changeType , targetChange .getTargetIdsList (), targetChange .getResumeToken (), cause );
928
+ watchChange = new WatchTargetChange (
929
+ changeType , targetChange .getTargetIdsList (), targetChange .getResumeToken (), cause );
917
930
break ;
918
931
case DOCUMENT_CHANGE :
919
932
DocumentChange docChange = protoChange .getDocumentChange ();
@@ -934,8 +947,7 @@ public WatchChange decodeWatchChange(ListenResponse protoChange) {
934
947
// Note that version might be unset in which case we use SnapshotVersion.NONE
935
948
version = decodeVersion (docDelete .getReadTime ());
936
949
MutableDocument doc = MutableDocument .newNoDocument (key , version );
937
- watchChange =
938
- new WatchChange .DocumentChange (Collections .emptyList (), removed , doc .getKey (), doc );
950
+ watchChange = new WatchChange .DocumentChange (Collections .emptyList (), removed , doc .getKey (), doc );
939
951
break ;
940
952
case DOCUMENT_REMOVE :
941
953
DocumentRemove docRemove = protoChange .getDocumentRemove ();
@@ -945,8 +957,7 @@ public WatchChange decodeWatchChange(ListenResponse protoChange) {
945
957
break ;
946
958
case FILTER :
947
959
com .google .firestore .v1 .ExistenceFilter protoFilter = protoChange .getFilter ();
948
- ExistenceFilter filter =
949
- new ExistenceFilter (protoFilter .getCount (), protoFilter .getUnchangedNames ());
960
+ ExistenceFilter filter = new ExistenceFilter (protoFilter .getCount (), protoFilter .getUnchangedNames ());
950
961
int targetId = protoFilter .getTargetId ();
951
962
watchChange = new ExistenceFilterWatchChange (targetId , filter );
952
963
break ;
@@ -959,8 +970,10 @@ public WatchChange decodeWatchChange(ListenResponse protoChange) {
959
970
}
960
971
961
972
public SnapshotVersion decodeVersionFromListenResponse (ListenResponse watchChange ) {
962
- // We have only reached a consistent snapshot for the entire stream if there is a read_time set
963
- // and it applies to all targets (i.e. the list of targets is empty). The backend is guaranteed
973
+ // We have only reached a consistent snapshot for the entire stream if there is
974
+ // a read_time set
975
+ // and it applies to all targets (i.e. the list of targets is empty). The
976
+ // backend is guaranteed
964
977
// to send such responses.
965
978
if (watchChange .getResponseTypeCase () != ResponseTypeCase .TARGET_CHANGE ) {
966
979
return SnapshotVersion .NONE ;
0 commit comments