/** * 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; }
@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 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()); }
public Builder mergeFrom(com.google.bigtable.v2.ReadModifyWriteRule other) { if (other == com.google.bigtable.v2.ReadModifyWriteRule.getDefaultInstance()) return this; if (!other.getFamilyName().isEmpty()) { familyName_ = other.familyName_; onChanged(); } if (other.getColumnQualifier() != com.google.protobuf.ByteString.EMPTY) { setColumnQualifier(other.getColumnQualifier()); } switch (other.getRuleCase()) { case APPEND_VALUE: { setAppendValue(other.getAppendValue()); break; } case INCREMENT_AMOUNT: { setIncrementAmount(other.getIncrementAmount()); break; } case RULE_NOT_SET: { break; } } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
public Builder mergeFrom(com.google.bigtable.v2.ReadModifyWriteRule other) { if (other == com.google.bigtable.v2.ReadModifyWriteRule.getDefaultInstance()) return this; if (!other.getFamilyName().isEmpty()) { familyName_ = other.familyName_; onChanged(); } if (other.getColumnQualifier() != com.google.protobuf.ByteString.EMPTY) { setColumnQualifier(other.getColumnQualifier()); } switch (other.getRuleCase()) { case APPEND_VALUE: { setAppendValue(other.getAppendValue()); break; } case INCREMENT_AMOUNT: { setIncrementAmount(other.getIncrementAmount()); break; } case RULE_NOT_SET: { break; } } onChanged(); return this; }
/** * 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; }
public Builder mergeFrom(com.google.bigtable.v2.ReadModifyWriteRule other) { if (other == com.google.bigtable.v2.ReadModifyWriteRule.getDefaultInstance()) return this; if (!other.getFamilyName().isEmpty()) { familyName_ = other.familyName_; onChanged(); } if (other.getColumnQualifier() != com.google.protobuf.ByteString.EMPTY) { setColumnQualifier(other.getColumnQualifier()); } switch (other.getRuleCase()) { case APPEND_VALUE: { setAppendValue(other.getAppendValue()); break; } case INCREMENT_AMOUNT: { setIncrementAmount(other.getIncrementAmount()); break; } case RULE_NOT_SET: { break; } } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }