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)
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + FAMILY_NAME_FIELD_NUMBER; hash = (53 * hash) + getFamilyName().hashCode(); hash = (37 * hash) + COLUMN_QUALIFIER_FIELD_NUMBER; hash = (53 * hash) + getColumnQualifier().hashCode(); hash = (37 * hash) + TIMESTAMP_MICROS_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getTimestampMicros()); hash = (37 * hash) + VALUE_FIELD_NUMBER; hash = (53 * hash) + getValue().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getFamilyNameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, familyName_); } if (!columnQualifier_.isEmpty()) { size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, columnQualifier_); } if (timestampMicros_ != 0L) { size += com.google.protobuf.CodedOutputStream.computeInt64Size(3, timestampMicros_); } if (!value_.isEmpty()) { size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, value_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
case 1: result = result && getSetCell() .equals(other.getSetCell()); break; case 2:
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)
switch (mutationCase_) { case 1: result = result && getSetCell().equals(other.getSetCell()); break; case 2:
if (setCellBuilder_ == null) { if (!(mutationCase_ == 1)) { mutation_ = com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance();
if (setCell.getTimestampMicros() == -1) { timestampHbase = HConstants.LATEST_TIMESTAMP; } else { timestampHbase = BigtableConstants.HBASE_TIMEUNIT.convert(setCell.getTimestampMicros(), BigtableConstants.BIGTABLE_TIMEUNIT); put.add(new RowCell(rowkeyArray, getBytes(setCell.getFamilyNameBytes()), getBytes(setCell.getColumnQualifier()), timestampHbase, getBytes(setCell.getValue())));
if (setCell.getTimestampMicros() == -1) { timestampHbase = HConstants.LATEST_TIMESTAMP; } else { timestampHbase = BigtableConstants.HBASE_TIMEUNIT.convert(setCell.getTimestampMicros(), BigtableConstants.BIGTABLE_TIMEUNIT); put.add(new RowCell(rowkeyArray, getBytes(setCell.getFamilyNameBytes()), getBytes(setCell.getColumnQualifier()), timestampHbase, getBytes(setCell.getValue())));
/** * <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(); } }
/** * <pre> * Set a cell's value. * </pre> * * <code>.google.bigtable.v2.Mutation.SetCell set_cell = 1;</code> */ private com.google.protobuf.SingleFieldBuilderV3< com.google.bigtable.v2.Mutation.SetCell, com.google.bigtable.v2.Mutation.SetCell.Builder, com.google.bigtable.v2.Mutation.SetCellOrBuilder> getSetCellFieldBuilder() { if (setCellBuilder_ == null) { if (!(mutationCase_ == 1)) { mutation_ = com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance(); } setCellBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< com.google.bigtable.v2.Mutation.SetCell, com.google.bigtable.v2.Mutation.SetCell.Builder, com.google.bigtable.v2.Mutation.SetCellOrBuilder>( (com.google.bigtable.v2.Mutation.SetCell) mutation_, getParentForChildren(), isClean()); mutation_ = null; } mutationCase_ = 1; onChanged();; return setCellBuilder_; }
@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 com.google.bigtable.v2.Mutation.SetCell getSetCell() { if (setCellBuilder_ == null) { if (mutationCase_ == 1) { return (com.google.bigtable.v2.Mutation.SetCell) mutation_; } return com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance(); } else { if (mutationCase_ == 1) { return setCellBuilder_.getMessage(); } return com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance(); } } /**
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getFamilyNameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, familyName_); } if (!columnQualifier_.isEmpty()) { size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, columnQualifier_); } if (timestampMicros_ != 0L) { size += com.google.protobuf.CodedOutputStream.computeInt64Size(3, timestampMicros_); } if (!value_.isEmpty()) { size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, value_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getFamilyNameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, familyName_); } if (!columnQualifier_.isEmpty()) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(2, columnQualifier_); } if (timestampMicros_ != 0L) { size += com.google.protobuf.CodedOutputStream .computeInt64Size(3, timestampMicros_); } if (!value_.isEmpty()) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(4, value_); } memoizedSize = size; return size; }
/** * * * <pre> * Set a cell's value. * </pre> * * <code>.google.bigtable.v2.Mutation.SetCell set_cell = 1;</code> */ public com.google.bigtable.v2.Mutation.SetCellOrBuilder getSetCellOrBuilder() { if ((mutationCase_ == 1) && (setCellBuilder_ != null)) { return setCellBuilder_.getMessageOrBuilder(); } else { if (mutationCase_ == 1) { return (com.google.bigtable.v2.Mutation.SetCell) mutation_; } return com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance(); } } /**
/** * <pre> * Set a cell's value. * </pre> * * <code>.google.bigtable.v2.Mutation.SetCell set_cell = 1;</code> */ public com.google.bigtable.v2.Mutation.SetCell getSetCell() { if (setCellBuilder_ == null) { if (mutationCase_ == 1) { return (com.google.bigtable.v2.Mutation.SetCell) mutation_; } return com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance(); } else { if (mutationCase_ == 1) { return setCellBuilder_.getMessage(); } return com.google.bigtable.v2.Mutation.SetCell.getDefaultInstance(); } } /**
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.bigtable.v2.Mutation.SetCell)) { return super.equals(obj); } com.google.bigtable.v2.Mutation.SetCell other = (com.google.bigtable.v2.Mutation.SetCell) obj; boolean result = true; result = result && getFamilyName() .equals(other.getFamilyName()); result = result && getColumnQualifier() .equals(other.getColumnQualifier()); result = result && (getTimestampMicros() == other.getTimestampMicros()); result = result && getValue() .equals(other.getValue()); return result; }
@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()); } }