@Override public Mutation setCell( @Nonnull String familyName, @Nonnull ByteString qualifier, long timestamp, @Nonnull ByteString value) { Validations.validateFamily(familyName); Preconditions.checkNotNull(qualifier, "qualifier can't be null."); Preconditions.checkNotNull(value, "value can't be null."); if (!allowServersideTimestamp) { Preconditions.checkArgument( timestamp != SERVER_SIDE_TIMESTAMP, "Serverside timestamps are not supported"); } addMutation( com.google.bigtable.v2.Mutation.newBuilder() .setSetCell( SetCell.newBuilder() .setFamilyName(familyName) .setColumnQualifier(qualifier) .setTimestampMicros(timestamp) .setValue(value) .build()) .build()); return this; }
/** * * * <pre> * Changes to be atomically applied to the specified row. Mutations are * applied in order, meaning that earlier mutations can be masked by * later ones. * You must specify at least one mutation. * </pre> * * <code>repeated .google.bigtable.v2.Mutation mutations = 2;</code> */ public Builder addMutations(com.google.bigtable.v2.Mutation.Builder builderForValue) { if (mutationsBuilder_ == null) { ensureMutationsIsMutable(); mutations_.add(builderForValue.build()); onChanged(); } else { mutationsBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * Changes to be atomically applied to the specified row. Mutations are * applied in order, meaning that earlier mutations can be masked by * later ones. * You must specify at least one mutation. * </pre> * * <code>repeated .google.bigtable.v2.Mutation mutations = 2;</code> */ public Builder setMutations( int index, com.google.bigtable.v2.Mutation.Builder builderForValue) { if (mutationsBuilder_ == null) { ensureMutationsIsMutable(); mutations_.set(index, builderForValue.build()); onChanged(); } else { mutationsBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
.setFamilyName("fake-family") .setColumnQualifier(ByteString.copyFromUtf8("fake-qualifier"))) .build(), com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( .setFamilyName("fake-family2") .setColumnQualifier(ByteString.copyFromUtf8("fake-qualifier2"))) .build(), com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( .setStartTimestampMicros(1000) .setEndTimestampMicros(2000))) .build());
/** * * * <pre> * Changes to be atomically applied to the specified row if `predicate_filter` * yields at least one cell when applied to `row_key`. Entries are applied in * order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry if `false_mutations` is empty, and at most * 100000. * </pre> * * <code>repeated .google.bigtable.v2.Mutation true_mutations = 4;</code> */ public Builder addTrueMutations( int index, com.google.bigtable.v2.Mutation.Builder builderForValue) { if (trueMutationsBuilder_ == null) { ensureTrueMutationsIsMutable(); trueMutations_.add(index, builderForValue.build()); onChanged(); } else { trueMutationsBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * Changes to be atomically applied to the specified row if `predicate_filter` * yields at least one cell when applied to `row_key`. Entries are applied in * order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry if `false_mutations` is empty, and at most * 100000. * </pre> * * <code>repeated .google.bigtable.v2.Mutation true_mutations = 4;</code> */ public Builder setTrueMutations( int index, com.google.bigtable.v2.Mutation.Builder builderForValue) { if (trueMutationsBuilder_ == null) { ensureTrueMutationsIsMutable(); trueMutations_.set(index, builderForValue.build()); onChanged(); } else { trueMutationsBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * Changes to be atomically applied to the specified row. Mutations are * applied in order, meaning that earlier mutations can be masked by * later ones. * You must specify at least one mutation. * </pre> * * <code>repeated .google.bigtable.v2.Mutation mutations = 2;</code> */ public Builder addMutations( int index, com.google.bigtable.v2.Mutation.Builder builderForValue) { if (mutationsBuilder_ == null) { ensureMutationsIsMutable(); mutations_.add(index, builderForValue.build()); onChanged(); } else { mutationsBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * Changes to be atomically applied to the specified row if `predicate_filter` * does not yield any cells when applied to `row_key`. Entries are applied in * order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry if `true_mutations` is empty, and at most * 100000. * </pre> * * <code>repeated .google.bigtable.v2.Mutation false_mutations = 5;</code> */ public Builder setFalseMutations( int index, com.google.bigtable.v2.Mutation.Builder builderForValue) { if (falseMutationsBuilder_ == null) { ensureFalseMutationsIsMutable(); falseMutations_.set(index, builderForValue.build()); onChanged(); } else { falseMutationsBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * Changes to be atomically applied to the specified row if `predicate_filter` * does not yield any cells when applied to `row_key`. Entries are applied in * order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry if `true_mutations` is empty, and at most * 100000. * </pre> * * <code>repeated .google.bigtable.v2.Mutation false_mutations = 5;</code> */ public Builder addFalseMutations( int index, com.google.bigtable.v2.Mutation.Builder builderForValue) { if (falseMutationsBuilder_ == null) { ensureFalseMutationsIsMutable(); falseMutations_.add(index, builderForValue.build()); onChanged(); } else { falseMutationsBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * Changes to be atomically applied to the specified row. Entries are applied * in order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry and at most 100000. * </pre> * * <code>repeated .google.bigtable.v2.Mutation mutations = 3;</code> */ public Builder addMutations(com.google.bigtable.v2.Mutation.Builder builderForValue) { if (mutationsBuilder_ == null) { ensureMutationsIsMutable(); mutations_.add(builderForValue.build()); onChanged(); } else { mutationsBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * Changes to be atomically applied to the specified row. Entries are applied * in order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry and at most 100000. * </pre> * * <code>repeated .google.bigtable.v2.Mutation mutations = 3;</code> */ public Builder addMutations( int index, com.google.bigtable.v2.Mutation.Builder builderForValue) { if (mutationsBuilder_ == null) { ensureMutationsIsMutable(); mutations_.add(index, builderForValue.build()); onChanged(); } else { mutationsBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * Changes to be atomically applied to the specified row. Entries are applied * in order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry and at most 100000. * </pre> * * <code>repeated .google.bigtable.v2.Mutation mutations = 3;</code> */ public Builder setMutations( int index, com.google.bigtable.v2.Mutation.Builder builderForValue) { if (mutationsBuilder_ == null) { ensureMutationsIsMutable(); mutations_.set(index, builderForValue.build()); onChanged(); } else { mutationsBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
@Test public void otherwiseTest() { ConditionalRowMutation mutation = ConditionalRowMutation.create(TABLE_ID, TEST_KEY) .otherwise(Mutation.create().deleteCells("family1", "qualifier1")) .otherwise(Mutation.create().deleteCells("family2", "qualifier2")); CheckAndMutateRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT); assertThat(actualProto.getFalseMutationsList()) .containsExactly( com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( DeleteFromColumn.newBuilder() .setFamilyName("family1") .setColumnQualifier(ByteString.copyFromUtf8("qualifier1"))) .build(), com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( DeleteFromColumn.newBuilder() .setFamilyName("family2") .setColumnQualifier(ByteString.copyFromUtf8("qualifier2"))) .build()) .inOrder(); }
/** * * * <pre> * Changes to be atomically applied to the specified row if `predicate_filter` * does not yield any cells when applied to `row_key`. Entries are applied in * order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry if `true_mutations` is empty, and at most * 100000. * </pre> * * <code>repeated .google.bigtable.v2.Mutation false_mutations = 5;</code> */ public Builder addFalseMutations(com.google.bigtable.v2.Mutation.Builder builderForValue) { if (falseMutationsBuilder_ == null) { ensureFalseMutationsIsMutable(); falseMutations_.add(builderForValue.build()); onChanged(); } else { falseMutationsBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * Changes to be atomically applied to the specified row if `predicate_filter` * yields at least one cell when applied to `row_key`. Entries are applied in * order, meaning that earlier mutations can be masked by later ones. * Must contain at least one entry if `false_mutations` is empty, and at most * 100000. * </pre> * * <code>repeated .google.bigtable.v2.Mutation true_mutations = 4;</code> */ public Builder addTrueMutations(com.google.bigtable.v2.Mutation.Builder builderForValue) { if (trueMutationsBuilder_ == null) { ensureTrueMutationsIsMutable(); trueMutations_.add(builderForValue.build()); onChanged(); } else { trueMutationsBuilder_.addMessage(builderForValue.build()); } return this; } /**
@Test public void thenTest() { ConditionalRowMutation mutation = ConditionalRowMutation.create(TABLE_ID, TEST_KEY) .then(Mutation.create().deleteCells("family1", "qualifier1")) .then(Mutation.create().deleteCells("family2", "qualifier2")); CheckAndMutateRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT); assertThat(actualProto.getTrueMutationsList()) .containsExactly( com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( DeleteFromColumn.newBuilder() .setFamilyName("family1") .setColumnQualifier(ByteString.copyFromUtf8("qualifier1"))) .build(), com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( DeleteFromColumn.newBuilder() .setFamilyName("family2") .setColumnQualifier(ByteString.copyFromUtf8("qualifier2"))) .build()) .inOrder(); }
@Override public Mutation deleteFamily(@Nonnull String familyName) { Validations.validateFamily(familyName); addMutation( com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromFamily(DeleteFromFamily.newBuilder().setFamilyName(familyName).build()) .build()); return this; }
@Test public void deleteFamilyTest() { mutation.deleteFamily("fake-family1").deleteFamily("fake-family2"); List<com.google.bigtable.v2.Mutation> actual = mutation.getMutations(); assertThat(actual) .containsExactly( com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromFamily(DeleteFromFamily.newBuilder().setFamilyName("fake-family1")) .build(), com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromFamily(DeleteFromFamily.newBuilder().setFamilyName("fake-family2")) .build()); }
@Override public Mutation deleteRow() { addMutation( com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromRow(DeleteFromRow.getDefaultInstance()) .build()); return this; }
@Test public void deleteRowTest() { mutation.deleteRow(); List<com.google.bigtable.v2.Mutation> actual = mutation.getMutations(); assertThat(actual) .containsExactly( com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromRow(DeleteFromRow.newBuilder()) .build()); }