if (!other.getTable().isEmpty()) { table_ = other.table_; onChanged(); bitField0_ = (bitField0_ & ~0x00000002); } else { ensureColumnsIsMutable(); columns_.addAll(other.columns_); onChanged(); bitField0_ = (bitField0_ & ~0x00000004); } else { ensureValuesIsMutable(); values_.addAll(other.values_); onChanged(); valuesBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getValuesFieldBuilder() : null; } else { this.mergeUnknownFields(other.unknownFields); onChanged(); return this;
private com.google.protobuf.RepeatedFieldBuilderV3< com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder> getValuesFieldBuilder() { if (valuesBuilder_ == null) { valuesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder>( values_, ((bitField0_ & 0x00000004) == 0x00000004), getParentForChildren(), isClean()); values_ = null; } return valuesBuilder_; }
&& mutation.columns.equals(last.columns)) { write.addValues(values); } else { if (proto != null) { throw new AssertionError("Impossible: " + mutation.operation); write.setTable(mutation.table).addAllColumns(mutation.columns).addValues(values);
com.google.spanner.v1.Mutation.Write.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom((com.google.spanner.v1.Mutation.Write) operation_); operation_ = subBuilder.buildPartial(); com.google.spanner.v1.Mutation.Write.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom((com.google.spanner.v1.Mutation.Write) operation_); operation_ = subBuilder.buildPartial(); com.google.spanner.v1.Mutation.Write.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom((com.google.spanner.v1.Mutation.Write) operation_); operation_ = subBuilder.buildPartial(); com.google.spanner.v1.Mutation.Write.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom((com.google.spanner.v1.Mutation.Write) operation_); operation_ = subBuilder.buildPartial();
&& mutation.columns.equals(last.columns)) { write.addValues(values); } else { if (proto != null) { throw new AssertionError("Impossible: " + mutation.operation); write.setTable(mutation.table).addAllColumns(mutation.columns).addValues(values);
com.google.spanner.v1.Mutation.Write.newBuilder( (com.google.spanner.v1.Mutation.Write) operation_) .mergeFrom(value) .buildPartial(); } else { operation_ = value;
com.google.spanner.v1.Mutation.Write.newBuilder( (com.google.spanner.v1.Mutation.Write) operation_) .mergeFrom(value) .buildPartial(); } else { operation_ = value;
com.google.spanner.v1.Mutation.Write.newBuilder( (com.google.spanner.v1.Mutation.Write) operation_) .mergeFrom(value) .buildPartial(); } else { operation_ = value;
com.google.spanner.v1.Mutation.Write.newBuilder( (com.google.spanner.v1.Mutation.Write) operation_) .mergeFrom(value) .buildPartial(); } else { operation_ = value;
/** * * * <pre> * The values to be written. `values` can contain more than one * list of values. If it does, then multiple rows are written, one * for each entry in `values`. Each list in `values` must have * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] * above. Sending multiple lists is equivalent to sending multiple * `Mutation`s, each containing one `values` entry and repeating * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are * encoded as described [here][google.spanner.v1.TypeCode]. * </pre> * * <code>repeated .google.protobuf.ListValue values = 3;</code> */ public Builder addValues(int index, com.google.protobuf.ListValue value) { if (valuesBuilder_ == null) { if (value == null) { throw new NullPointerException(); } ensureValuesIsMutable(); values_.add(index, value); onChanged(); } else { valuesBuilder_.addMessage(index, value); } return this; } /**
/** * * * <pre> * The values to be written. `values` can contain more than one * list of values. If it does, then multiple rows are written, one * for each entry in `values`. Each list in `values` must have * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] * above. Sending multiple lists is equivalent to sending multiple * `Mutation`s, each containing one `values` entry and repeating * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are * encoded as described [here][google.spanner.v1.TypeCode]. * </pre> * * <code>repeated .google.protobuf.ListValue values = 3;</code> */ public Builder addValues(com.google.protobuf.ListValue value) { if (valuesBuilder_ == null) { if (value == null) { throw new NullPointerException(); } ensureValuesIsMutable(); values_.add(value); onChanged(); } else { valuesBuilder_.addMessage(value); } return this; } /**
/** * * * <pre> * The values to be written. `values` can contain more than one * list of values. If it does, then multiple rows are written, one * for each entry in `values`. Each list in `values` must have * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] * above. Sending multiple lists is equivalent to sending multiple * `Mutation`s, each containing one `values` entry and repeating * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are * encoded as described [here][google.spanner.v1.TypeCode]. * </pre> * * <code>repeated .google.protobuf.ListValue values = 3;</code> */ public Builder addAllValues( java.lang.Iterable<? extends com.google.protobuf.ListValue> values) { if (valuesBuilder_ == null) { ensureValuesIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll(values, values_); onChanged(); } else { valuesBuilder_.addAllMessages(values); } return this; } /**
/** * * * <pre> * The values to be written. `values` can contain more than one * list of values. If it does, then multiple rows are written, one * for each entry in `values`. Each list in `values` must have * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] * above. Sending multiple lists is equivalent to sending multiple * `Mutation`s, each containing one `values` entry and repeating * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are * encoded as described [here][google.spanner.v1.TypeCode]. * </pre> * * <code>repeated .google.protobuf.ListValue values = 3;</code> */ public Builder setValues(int index, com.google.protobuf.ListValue value) { if (valuesBuilder_ == null) { if (value == null) { throw new NullPointerException(); } ensureValuesIsMutable(); values_.set(index, value); onChanged(); } else { valuesBuilder_.setMessage(index, value); } return this; } /**
/** * * * <pre> * The values to be written. `values` can contain more than one * list of values. If it does, then multiple rows are written, one * for each entry in `values`. Each list in `values` must have * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] * above. Sending multiple lists is equivalent to sending multiple * `Mutation`s, each containing one `values` entry and repeating * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are * encoded as described [here][google.spanner.v1.TypeCode]. * </pre> * * <code>repeated .google.protobuf.ListValue values = 3;</code> */ public Builder addValues(int index, com.google.protobuf.ListValue.Builder builderForValue) { if (valuesBuilder_ == null) { ensureValuesIsMutable(); values_.add(index, builderForValue.build()); onChanged(); } else { valuesBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The values to be written. `values` can contain more than one * list of values. If it does, then multiple rows are written, one * for each entry in `values`. Each list in `values` must have * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] * above. Sending multiple lists is equivalent to sending multiple * `Mutation`s, each containing one `values` entry and repeating * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are * encoded as described [here][google.spanner.v1.TypeCode]. * </pre> * * <code>repeated .google.protobuf.ListValue values = 3;</code> */ public Builder addValues(com.google.protobuf.ListValue.Builder builderForValue) { if (valuesBuilder_ == null) { ensureValuesIsMutable(); values_.add(builderForValue.build()); onChanged(); } else { valuesBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * The values to be written. `values` can contain more than one * list of values. If it does, then multiple rows are written, one * for each entry in `values`. Each list in `values` must have * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] * above. Sending multiple lists is equivalent to sending multiple * `Mutation`s, each containing one `values` entry and repeating * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are * encoded as described [here][google.spanner.v1.TypeCode]. * </pre> * * <code>repeated .google.protobuf.ListValue values = 3;</code> */ public Builder removeValues(int index) { if (valuesBuilder_ == null) { ensureValuesIsMutable(); values_.remove(index); onChanged(); } else { valuesBuilder_.remove(index); } return this; } /**
/** * * * <pre> * The values to be written. `values` can contain more than one * list of values. If it does, then multiple rows are written, one * for each entry in `values`. Each list in `values` must have * exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] * above. Sending multiple lists is equivalent to sending multiple * `Mutation`s, each containing one `values` entry and repeating * [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are * encoded as described [here][google.spanner.v1.TypeCode]. * </pre> * * <code>repeated .google.protobuf.ListValue values = 3;</code> */ public Builder setValues(int index, com.google.protobuf.ListValue.Builder builderForValue) { if (valuesBuilder_ == null) { ensureValuesIsMutable(); values_.set(index, builderForValue.build()); onChanged(); } else { valuesBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
@Test public void writeAtLeastOnce() throws ParseException { String timestampString = "2015-10-01T10:54:20.021Z"; ArgumentCaptor<CommitRequest> commit = ArgumentCaptor.forClass(CommitRequest.class); CommitResponse response = CommitResponse.newBuilder().setCommitTimestamp(Timestamps.parse(timestampString)).build(); Mockito.when(rpc.commit(commit.capture(), Mockito.eq(options))).thenReturn(response); Timestamp timestamp = session.writeAtLeastOnce( Arrays.asList(Mutation.newInsertBuilder("T").set("C").to("x").build())); assertThat(timestamp.getSeconds()) .isEqualTo(utcTimeSeconds(2015, Calendar.OCTOBER, 1, 10, 54, 20)); assertThat(timestamp.getNanos()).isEqualTo(TimeUnit.MILLISECONDS.toNanos(21)); CommitRequest request = commit.getValue(); assertThat(request.getSingleUseTransaction()).isNotNull(); assertThat(request.getSingleUseTransaction().getReadWrite()).isNotNull(); com.google.spanner.v1.Mutation mutation = com.google.spanner.v1.Mutation.newBuilder() .setInsert( Write.newBuilder() .setTable("T") .addColumns("C") .addValues( ListValue.newBuilder() .addValues(com.google.protobuf.Value.newBuilder().setStringValue("x")))) .build(); assertThat(request.getMutationsList()).containsExactly(mutation); }
/** * * * <pre> * Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is * deleted, and the column values provided are inserted * instead. Unlike [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this means any values not * explicitly written become `NULL`. * </pre> * * <code>.google.spanner.v1.Mutation.Write replace = 4;</code> */ public Builder setReplace(com.google.spanner.v1.Mutation.Write.Builder builderForValue) { if (replaceBuilder_ == null) { operation_ = builderForValue.build(); onChanged(); } else { replaceBuilder_.setMessage(builderForValue.build()); } operationCase_ = 4; return this; } /**
/** * * * <pre> * The names of the columns in [table][google.spanner.v1.Mutation.Write.table] to be written. * The list of columns must contain enough columns to allow * Cloud Spanner to derive values for all primary key columns in the * row(s) to be modified. * </pre> * * <code>repeated string columns = 2;</code> */ public Builder addColumnsBytes(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); ensureColumnsIsMutable(); columns_.add(value); onChanged(); return this; }