@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> * Set a cell's value. * </pre> * * <code>.google.bigtable.v2.Mutation.SetCell set_cell = 1;</code> */ public Builder setSetCell(com.google.bigtable.v2.Mutation.SetCell.Builder builderForValue) { if (setCellBuilder_ == null) { mutation_ = builderForValue.build(); onChanged(); } else { setCellBuilder_.setMessage(builderForValue.build()); } mutationCase_ = 1; return this; } /**
@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; }
/** * This test ensures that protobuf creation and interactions with {@link BulkMutation} work as * expected. * * @throws IOException * @throws InterruptedException */ @Test public void testWrite() throws IOException, InterruptedException { BigtableService.Writer underTest = new BigtableServiceImpl.BigtableWriterImpl(mockSession, TABLE_NAME); Mutation mutation = Mutation.newBuilder() .setSetCell(SetCell.newBuilder().setFamilyName("Family").build()) .build(); ByteString key = ByteString.copyFromUtf8("key"); SettableFuture<MutateRowResponse> fakeResponse = SettableFuture.create(); when(mockBulkMutation.add(any(MutateRowsRequest.Entry.class))).thenReturn(fakeResponse); underTest.writeRecord(KV.of(key, ImmutableList.of(mutation))); Entry expected = MutateRowsRequest.Entry.newBuilder().setRowKey(key).addMutations(mutation).build(); verify(mockBulkMutation, times(1)).add(expected); underTest.close(); verify(mockBulkMutation, times(1)).flush(); } }
@Override public KV<ByteString, Iterable<Mutation>> apply(BigtableRow row) { ByteString key = toByteString(row.getKey()); // BulkMutation doesn't split rows. Currently, if a single row contains more than 100,000 // mutations, the service will fail the request. ImmutableList.Builder<Mutation> mutations = ImmutableList.builder(); for (BigtableCell cell : row.getCells()) { SetCell setCell = SetCell.newBuilder() .setFamilyName(cell.getFamily().toString()) .setColumnQualifier(toByteString(cell.getQualifier())) .setTimestampMicros(cell.getTimestamp()) .setValue(toByteString(cell.getValue())) .build(); mutations.add(Mutation.newBuilder().setSetCell(setCell).build()); } return KV.of(key, mutations.build()); } }
/** * * * <pre> * Set a cell's value. * </pre> * * <code>.google.bigtable.v2.Mutation.SetCell set_cell = 1;</code> */ public Builder setSetCell(com.google.bigtable.v2.Mutation.SetCell.Builder builderForValue) { if (setCellBuilder_ == null) { mutation_ = builderForValue.build(); onChanged(); } else { setCellBuilder_.setMessage(builderForValue.build()); } mutationCase_ = 1; return this; } /**
/** * <pre> * Set a cell's value. * </pre> * * <code>.google.bigtable.v2.Mutation.SetCell set_cell = 1;</code> */ public Builder setSetCell( com.google.bigtable.v2.Mutation.SetCell.Builder builderForValue) { if (setCellBuilder_ == null) { mutation_ = builderForValue.build(); onChanged(); } else { setCellBuilder_.setMessage(builderForValue.build()); } mutationCase_ = 1; return this; } /**