/** * 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 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()); }
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; } } 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; }
/** * 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; }