final SetCell.Builder setCellBuilder = mutationBuilder.getSetCellBuilder(); setCellBuilder.setFamilyNameBytes(ByteStringer.wrap(columnFamilyBytes)); setCellBuilder.setColumnQualifier(ByteStringer.wrap(entry.getKey().getBytes())); setCellBuilder.setValue(ByteStringer.wrap(entry.getValue().toArray())); setCellBuilder.setTimestampMicros(System.currentTimeMillis() * 1000);
@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; }
com.google.bigtable.v2.Mutation.SetCell.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom((com.google.bigtable.v2.Mutation.SetCell) mutation_); mutation_ = subBuilder.buildPartial();
com.google.bigtable.v2.Mutation.SetCell.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom((com.google.bigtable.v2.Mutation.SetCell) mutation_); mutation_ = subBuilder.buildPartial();
input.readMessage(com.google.bigtable.v2.Mutation.SetCell.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom((com.google.bigtable.v2.Mutation.SetCell) mutation_); mutation_ = subBuilder.buildPartial();
com.google.bigtable.v2.Mutation.SetCell.newBuilder( (com.google.bigtable.v2.Mutation.SetCell) mutation_) .mergeFrom(value) .buildPartial(); } else { mutation_ = value;
/** * <pre> * Set a cell's value. * </pre> * * <code>.google.bigtable.v2.Mutation.SetCell set_cell = 1;</code> */ public Builder mergeSetCell(com.google.bigtable.v2.Mutation.SetCell value) { if (setCellBuilder_ == null) { if (mutationCase_ == 1 && mutation_ != com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance()) { mutation_ = com.google.bigtable.v2.Mutation.SetCell.newBuilder((com.google.bigtable.v2.Mutation.SetCell) mutation_) .mergeFrom(value).buildPartial(); } else { mutation_ = value; } onChanged(); } else { if (mutationCase_ == 1) { setCellBuilder_.mergeFrom(value); } setCellBuilder_.setMessage(value); } mutationCase_ = 1; 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 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; } /**
/** * <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 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()); } }
public Builder mergeFrom(com.google.bigtable.v2.Mutation.SetCell other) { if (other == com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance()) return this; if (!other.getFamilyName().isEmpty()) { familyName_ = other.familyName_; onChanged(); } if (other.getColumnQualifier() != com.google.protobuf.ByteString.EMPTY) { setColumnQualifier(other.getColumnQualifier()); } if (other.getTimestampMicros() != 0L) { setTimestampMicros(other.getTimestampMicros()); } if (other.getValue() != com.google.protobuf.ByteString.EMPTY) { setValue(other.getValue()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
public Builder mergeFrom(com.google.bigtable.v2.Mutation.SetCell other) { if (other == com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance()) return this; if (!other.getFamilyName().isEmpty()) { familyName_ = other.familyName_; onChanged(); } if (other.getColumnQualifier() != com.google.protobuf.ByteString.EMPTY) { setColumnQualifier(other.getColumnQualifier()); } if (other.getTimestampMicros() != 0L) { setTimestampMicros(other.getTimestampMicros()); } if (other.getValue() != com.google.protobuf.ByteString.EMPTY) { setValue(other.getValue()); } onChanged(); return this; }
@ProcessElement public void processElement(ProcessContext c) { int index = c.element().intValue(); Iterable<Mutation> mutations = ImmutableList.of( Mutation.newBuilder() .setSetCell( Mutation.SetCell.newBuilder() .setValue(testData.get(index).getValue()) .setFamilyName(COLUMN_FAMILY_NAME)) .build()); c.output(KV.of(testData.get(index).getKey(), mutations)); } }))
private Builder() { maybeForceBuilderInitialization(); }
private Builder() { maybeForceBuilderInitialization(); }
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); }