@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
/** * Appends the value to the existing value of the cell. If the targeted cell is unset, it will be * treated as containing the empty string. */ public ReadModifyWriteRow append( @Nonnull String familyName, @Nonnull ByteString qualifier, @Nonnull ByteString value) { Validations.validateFamily(familyName); Preconditions.checkNotNull(qualifier, "Qualifier can't be null"); Preconditions.checkNotNull(value, "Value can't be null"); Preconditions.checkArgument(!value.isEmpty(), "Value can't be empty"); ReadModifyWriteRule rule = ReadModifyWriteRule.newBuilder() .setFamilyName(familyName) .setColumnQualifier(qualifier) .setAppendValue(value) .build(); builder.addRules(rule); return this; }
/** * Adds `amount` be added to the existing value. If the targeted cell is unset, it will be treated * as containing a zero. Otherwise, the targeted cell must contain an 8-byte value (interpreted as * a 64-bit big-endian signed integer), or the entire request will fail. */ public ReadModifyWriteRow increment( @Nonnull String familyName, @Nonnull ByteString qualifier, long amount) { Validations.validateFamily(familyName); Preconditions.checkNotNull(qualifier, "Qualifier can't be null"); ReadModifyWriteRule rule = ReadModifyWriteRule.newBuilder() .setFamilyName(familyName) .setColumnQualifier(qualifier) .setIncrementAmount(amount) .build(); builder.addRules(rule); return this; }
@Test public void testAppend() { ReadModifyWriteRow mutation = ReadModifyWriteRow.create(TABLE_ID, "fake-key") .append( "fake-family", ByteString.copyFromUtf8("fake-qualifier"), ByteString.copyFromUtf8("fake-value")) .append("fake-family", "fake-qualifier-str", "fake-value-str"); ReadModifyWriteRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT); ReadModifyWriteRowRequest expected = ReadModifyWriteRowRequest.newBuilder() .setTableName(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID)) .setAppProfileId(APP_PROFILE_ID) .setRowKey(ByteString.copyFromUtf8("fake-key")) .addRules( ReadModifyWriteRule.newBuilder() .setFamilyName("fake-family") .setColumnQualifier(ByteString.copyFromUtf8("fake-qualifier")) .setAppendValue(ByteString.copyFromUtf8("fake-value"))) .addRules( ReadModifyWriteRule.newBuilder() .setFamilyName("fake-family") .setColumnQualifier(ByteString.copyFromUtf8("fake-qualifier-str")) .setAppendValue(ByteString.copyFromUtf8("fake-value-str"))) .build(); assertThat(actualProto).isEqualTo(expected); }
@Test public void testIncrement() { ReadModifyWriteRow mutation = ReadModifyWriteRow.create(TABLE_ID, "fake-key") .increment("fake-family", ByteString.copyFromUtf8("fake-qualifier"), 1) .increment("fake-family", "fake-qualifier-str", 2); ReadModifyWriteRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT); assertThat(actualProto) .isEqualTo( ReadModifyWriteRowRequest.newBuilder() .setTableName(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID)) .setAppProfileId(APP_PROFILE_ID) .setRowKey(ByteString.copyFromUtf8("fake-key")) .addRules( ReadModifyWriteRule.newBuilder() .setFamilyName("fake-family") .setColumnQualifier(ByteString.copyFromUtf8("fake-qualifier")) .setIncrementAmount(1)) .addRules( ReadModifyWriteRule.newBuilder() .setFamilyName("fake-family") .setColumnQualifier(ByteString.copyFromUtf8("fake-qualifier-str")) .setIncrementAmount(2)) .build()); }
@Test public void requestIsCorrect() { callable.futureCall( ReadModifyWriteRow.create("my-table", "my-key").append("my-family", "", "suffix")); assertThat(inner.request) .isEqualTo( ReadModifyWriteRowRequest.newBuilder() .setTableName( NameUtil.formatTableName( requestContext.getProjectId(), requestContext.getInstanceId(), "my-table")) .setAppProfileId(requestContext.getAppProfileId()) .setRowKey(ByteString.copyFromUtf8("my-key")) .addRules( ReadModifyWriteRule.newBuilder() .setFamilyName("my-family") .setColumnQualifier(ByteString.EMPTY) .setAppendValue(ByteString.copyFromUtf8("suffix"))) .build()); }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
/** * Appends the value to the existing value of the cell. If the targeted cell is unset, it will be * treated as containing the empty string. */ public ReadModifyWriteRow append( @Nonnull String familyName, @Nonnull ByteString qualifier, @Nonnull ByteString value) { Validations.validateFamily(familyName); Preconditions.checkNotNull(qualifier, "Qualifier can't be null"); Preconditions.checkNotNull(value, "Value can't be null"); Preconditions.checkArgument(!value.isEmpty(), "Value can't be empty"); ReadModifyWriteRule rule = ReadModifyWriteRule.newBuilder() .setFamilyName(familyName) .setColumnQualifier(qualifier) .setAppendValue(value) .build(); builder.addRules(rule); return this; }
/** * Adds `amount` be added to the existing value. If the targeted cell is unset, it will be treated * as containing a zero. Otherwise, the targeted cell must contain an 8-byte value (interpreted as * a 64-bit big-endian signed integer), or the entire request will fail. */ public ReadModifyWriteRow increment( @Nonnull String familyName, @Nonnull ByteString qualifier, long amount) { Validations.validateFamily(familyName); Preconditions.checkNotNull(qualifier, "Qualifier can't be null"); ReadModifyWriteRule rule = ReadModifyWriteRule.newBuilder() .setFamilyName(familyName) .setColumnQualifier(qualifier) .setIncrementAmount(amount) .build(); builder.addRules(rule); return this; }