@@ -90,14 +90,10 @@ public enum Op {
9090 /** Deletes rows from a table. Succeeds whether or not the named rows were present. */
9191 DELETE ,
9292
93- /**
94- * Send a message to a queue, optionally with specified delivery time.
95- */
93+ /** Send a message to a queue, optionally with specified delivery time. */
9694 SEND ,
9795
98- /**
99- * Acknowledge a message in a queue. Ack only succeeds if the message still exists.
100- */
96+ /** Acknowledge a message in a queue. Ack only succeeds if the message still exists. */
10197 ACK ,
10298 }
10399
@@ -191,16 +187,16 @@ public static Mutation delete(String table, KeySet keySet) {
191187 }
192188
193189 /**
194- * Returns a builder that can be used to construct an {@link Op#SEND} mutation against {@code queue}; see the
195- * {@code SEND} documentation for mutation semantics.
190+ * Returns a builder that can be used to construct an {@link Op#SEND} mutation against {@code
191+ * queue}; see the {@code SEND} documentation for mutation semantics.
196192 */
197193 public static SendBuilder newSendBuilder (String queue ) {
198194 return new SendBuilder (queue );
199195 }
200196
201197 /**
202- * Returns a builder that can be used to construct an {@link Op#ACK} mutation against {@code queue}; see the
203- * {@code ACK} documentation for mutation semantics.
198+ * Returns a builder that can be used to construct an {@link Op#ACK} mutation against {@code
199+ * queue}; see the {@code ACK} documentation for mutation semantics.
204200 */
205201 public static AckBuilder newAckBuilder (String queue ) {
206202 return new AckBuilder (queue );
@@ -280,9 +276,7 @@ private void checkDuplicateColumns(ImmutableList<String> columnNames) {
280276 }
281277 }
282278
283- /**
284- * Builder for {@link Op#SEND} mutation.
285- */
279+ /** Builder for {@link Op#SEND} mutation. */
286280 public static class SendBuilder {
287281 private final String queue ;
288282 private Key key ;
@@ -311,13 +305,12 @@ public SendBuilder setDeliveryTime(Instant deliveryTime) {
311305 public Mutation build () {
312306 checkState (key != null , "Key must be set for Send mutation" );
313307 checkState (payload != null , "Payload must be set for Send mutation" );
314- return new Mutation (null , Op .SEND , null , null , null , queue , key , payload , deliveryTime , false );
308+ return new Mutation (
309+ null , Op .SEND , null , null , null , queue , key , payload , deliveryTime , false );
315310 }
316311 }
317312
318- /**
319- * Builder for {@link Op#ACK} mutation.
320- */
313+ /** Builder for {@link Op#ACK} mutation. */
321314 public static class AckBuilder {
322315 private final String queue ;
323316 private Key key ;
@@ -364,30 +357,34 @@ public Iterable<String> getColumns() {
364357 }
365358
366359 /**
367- * For all types except {@link Op#DELETE}, {@link Op#SEND}, and {@link Op#ACK}, returns the values that this mutation
368- * will write. The number of elements returned is always the same as the number returned by {@link #getColumns()},
369- * and the {@code i}th value corresponds to the {@code i}th column.
360+ * For all types except {@link Op#DELETE}, {@link Op#SEND}, and {@link Op#ACK}, returns the values
361+ * that this mutation will write. The number of elements returned is always the same as the number
362+ * returned by {@link #getColumns()}, and the {@code i}th value corresponds to the {@code i}th
363+ * column.
370364 *
371- * @throws IllegalStateException
372- * if {@code operation() == Op.DELETE or operation() == Op.SEND or operation() == Op.ACK}
365+ * @throws IllegalStateException if {@code operation() == Op.DELETE or operation() == Op.SEND or
366+ * operation() == Op.ACK}
373367 */
374368 public Iterable <Value > getValues () {
375- checkState (operation != Op .DELETE && operation != Op .SEND && operation != Op .ACK ,
369+ checkState (
370+ operation != Op .DELETE && operation != Op .SEND && operation != Op .ACK ,
376371 "values() cannot be called for a DELETE/SEND/ACK mutation" );
377372 return values ;
378373 }
379374
380375 /** Returns the name of the queue that this mutation will affect. */
381376 public String getQueue () {
382- checkState (operation == Op .SEND || operation == Op .ACK , "getQueue() can only be called " +
383- "for SEND or ACK mutations" );
377+ checkState (
378+ operation == Op .SEND || operation == Op .ACK ,
379+ "getQueue() can only be called " + "for SEND or ACK mutations" );
384380 return queue ;
385381 }
386382
387383 /** Returns the key of the message to the queue that this mutation will affect. */
388384 public Key getKey () {
389- checkState (operation == Op .SEND || operation == Op .ACK , "getKey() can only be called for " +
390- "SEND or ACK mutations" );
385+ checkState (
386+ operation == Op .SEND || operation == Op .ACK ,
387+ "getKey() can only be called for " + "SEND or ACK mutations" );
391388 return key ;
392389 }
393390
@@ -404,22 +401,27 @@ public Instant getDeliveryTime() {
404401 return deliveryTime ;
405402 }
406403
407- /** Returns whether an error will be ignored for an ACK mutation that affects a message that does not exist */
404+ /**
405+ * Returns whether an error will be ignored for an ACK mutation that affects a message that does
406+ * not exist
407+ */
408408 public boolean getIgnoreNotFound () {
409409 checkState (operation == Op .ACK , "getIgnoreNotFound() can only be called for an ACK mutation" );
410410 return ignoreNotFound ;
411411 }
412412
413413 /**
414- * For all types except {@link Op#DELETE}, {@link Op#SEND}, and {@link Op#ACK}, constructs a map from column name to
415- * value. This is mainly intended as a convenience for testing; direct access via {@link #getColumns()} and
416- * {@link #getValues()} is more efficient.
414+ * For all types except {@link Op#DELETE}, {@link Op#SEND}, and {@link Op#ACK}, constructs a map
415+ * from column name to value. This is mainly intended as a convenience for testing; direct access
416+ * via {@link #getColumns()} and {@link #getValues()} is more efficient.
417417 *
418- * @throws IllegalStateException if {@code operation() == Op.DELETE or operation() == Op.SEND or operation() ==
419- * Op.ACK}, or if any duplicate columns are present. Detection of duplicates does not consider case.
418+ * @throws IllegalStateException if {@code operation() == Op.DELETE or operation() == Op.SEND or
419+ * operation() == Op.ACK}, or if any duplicate columns are present. Detection of duplicates
420+ * does not consider case.
420421 */
421422 public Map <String , Value > asMap () {
422- checkState (operation != Op .DELETE && operation != Op .SEND && operation != Op .ACK ,
423+ checkState (
424+ operation != Op .DELETE && operation != Op .SEND && operation != Op .ACK ,
423425 "asMap() cannot be called for a DELETE/SEND/ACK mutation" );
424426 LinkedHashMap <String , Value > map = new LinkedHashMap <>();
425427 for (int i = 0 ; i < columns .size (); ++i ) {
@@ -544,7 +546,8 @@ && areValuesEqual(values, that.values)
544546
545547 @ Override
546548 public int hashCode () {
547- return Objects .hash (operation , table , columns , values , keySet , key , payload , deliveryTime , ignoreNotFound );
549+ return Objects .hash (
550+ operation , table , columns , values , keySet , key , payload , deliveryTime , ignoreNotFound );
548551 }
549552
550553 /**
@@ -622,7 +625,8 @@ static com.google.spanner.v1.Mutation toProtoAndReturnRandomMutation(
622625 if (last != null && last .operation == Op .DELETE && mutation .table .equals (last .table )) {
623626 mutation .keySet .appendToProto (keySet );
624627 } else {
625- largestInsertMutation = flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
628+ largestInsertMutation =
629+ flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
626630 proto = com .google .spanner .v1 .Mutation .newBuilder ();
627631 com .google .spanner .v1 .Mutation .Delete .Builder delete =
628632 proto .getDeleteBuilder ().setTable (mutation .table );
@@ -631,23 +635,29 @@ static com.google.spanner.v1.Mutation toProtoAndReturnRandomMutation(
631635 }
632636 write = null ;
633637 } else if (mutation .operation == Op .SEND ) {
634- largestInsertMutation = flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
638+ largestInsertMutation =
639+ flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
635640 proto = com .google .spanner .v1 .Mutation .newBuilder ();
636- com .google .spanner .v1 .Mutation .Send .Builder send = proto .getSendBuilder ()
637- .setQueue (mutation .queue )
638- .setKey (mutation .key .toProto ())
639- .setPayload (mutation .payload .toProto ());
641+ com .google .spanner .v1 .Mutation .Send .Builder send =
642+ proto
643+ .getSendBuilder ()
644+ .setQueue (mutation .queue )
645+ .setKey (mutation .key .toProto ())
646+ .setPayload (mutation .payload .toProto ());
640647 if (mutation .getDeliveryTime () != null ) {
641648 Instant deliveryTime = mutation .getDeliveryTime ();
642- Timestamp .Builder timeBuilder = send .getDeliverTimeBuilder ()
643- .setSeconds (deliveryTime .getEpochSecond ())
644- .setNanos (deliveryTime .getNano ());
649+ Timestamp .Builder timeBuilder =
650+ send .getDeliverTimeBuilder ()
651+ .setSeconds (deliveryTime .getEpochSecond ())
652+ .setNanos (deliveryTime .getNano ());
645653 send .setDeliverTime (timeBuilder );
646654 }
647655 } else if (mutation .operation == Op .ACK ) {
648- largestInsertMutation = flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
656+ largestInsertMutation =
657+ flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
649658 proto = com .google .spanner .v1 .Mutation .newBuilder ();
650- proto .getAckBuilder ()
659+ proto
660+ .getAckBuilder ()
651661 .setQueue (mutation .queue )
652662 .setKey (mutation .getKey ().toProto ())
653663 .setIgnoreNotFound (mutation .ignoreNotFound );
@@ -663,7 +673,8 @@ static com.google.spanner.v1.Mutation toProtoAndReturnRandomMutation(
663673 // Same as previous mutation: coalesce values to reduce request size.
664674 write .addValues (values );
665675 } else {
666- largestInsertMutation = flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
676+ largestInsertMutation =
677+ flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
667678 proto = com .google .spanner .v1 .Mutation .newBuilder ();
668679 switch (mutation .operation ) {
669680 case INSERT :
@@ -688,7 +699,8 @@ static com.google.spanner.v1.Mutation toProtoAndReturnRandomMutation(
688699 last = mutation ;
689700 }
690701 // Flush last item.
691- largestInsertMutation = flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
702+ largestInsertMutation =
703+ flushMutation (out , proto , allMutationsExcludingInsert , largestInsertMutation );
692704
693705 // Select a random mutation based on the heuristic.
694706 if (!allMutationsExcludingInsert .isEmpty ()) {
@@ -699,10 +711,11 @@ static com.google.spanner.v1.Mutation toProtoAndReturnRandomMutation(
699711 }
700712 }
701713
702- private static com .google .spanner .v1 .Mutation flushMutation (List <com .google .spanner .v1 .Mutation > out ,
703- com .google .spanner .v1 .Mutation .Builder proto ,
704- List <com .google .spanner .v1 .Mutation > allMutationsExcludingInsert ,
705- com .google .spanner .v1 .Mutation largestInsertMutation ) {
714+ private static com .google .spanner .v1 .Mutation flushMutation (
715+ List <com .google .spanner .v1 .Mutation > out ,
716+ com .google .spanner .v1 .Mutation .Builder proto ,
717+ List <com .google .spanner .v1 .Mutation > allMutationsExcludingInsert ,
718+ com .google .spanner .v1 .Mutation largestInsertMutation ) {
706719 if (proto != null ) {
707720 com .google .spanner .v1 .Mutation builtMutation = proto .build ();
708721 out .add (builtMutation );
0 commit comments