use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable-hbase by googleapis.
the class HBaseRequestAdapter method adapt.
/**
* adapt.
*
* @param mutation a {@link org.apache.hadoop.hbase.client.Mutation} object.
* @return a {@link RowMutation} object.
*/
public RowMutation adapt(org.apache.hadoop.hbase.client.Mutation mutation) {
RowMutation rowMutation = newRowMutationModel(mutation.getRow());
adapt(mutation, rowMutation);
return rowMutation;
}
use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable-hbase by googleapis.
the class AbstractBigtableTable method delete.
/**
* {@inheritDoc}
*/
@Override
public void delete(Delete delete) throws IOException {
LOG.trace("delete(Delete)");
RowMutation rowMutation = hbaseAdapter.adapt(delete);
mutateRow(delete, rowMutation, "delete");
}
use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable-hbase by googleapis.
the class TestRowMutationsAdapter method toMutateRowRequest.
private MutateRowRequest toMutateRowRequest(byte[] rowKey, com.google.cloud.bigtable.data.v2.models.Mutation mutation) {
RowMutation rowMutation = toRowMutationModel(rowKey, mutation);
MutateRowRequest.Builder builder = rowMutation.toProto(REQUEST_CONTEXT).toBuilder();
return builder.build();
}
use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable-hbase by googleapis.
the class TestPutAdapter method testUnsetTimestampsAreNotPopulated.
@Test
public void testUnsetTimestampsAreNotPopulated() {
PutAdapter adapter = new PutAdapter(-1, false);
byte[] row = dataHelper.randomData("rk-");
byte[] family1 = dataHelper.randomData("f1");
byte[] qualifier1 = dataHelper.randomData("qual1");
byte[] value1 = dataHelper.randomData("v1");
Put hbasePut = new Put(row).addColumn(family1, qualifier1, value1);
com.google.cloud.bigtable.data.v2.models.Mutation unsafeMutation = com.google.cloud.bigtable.data.v2.models.Mutation.createUnsafe();
adapter.adapt(hbasePut, unsafeMutation);
RowMutation rowMutation = RowMutation.create(TABLE_ID, ByteString.copyFrom(hbasePut.getRow()), unsafeMutation);
MutateRowRequest request = rowMutation.toProto(REQUEST_CONTEXT);
Assert.assertArrayEquals(row, request.getRowKey().toByteArray());
Assert.assertEquals(1, request.getMutationsCount());
Mutation mutation = request.getMutations(0);
Assert.assertEquals(MutationCase.SET_CELL, mutation.getMutationCase());
SetCell setCell = mutation.getSetCell();
Assert.assertArrayEquals(family1, setCell.getFamilyNameBytes().toByteArray());
Assert.assertArrayEquals(qualifier1, setCell.getColumnQualifier().toByteArray());
Assert.assertEquals(-1, setCell.getTimestampMicros());
Assert.assertArrayEquals(value1, setCell.getValue().toByteArray());
}
use of com.google.cloud.bigtable.data.v2.models.RowMutation in project java-bigtable-hbase by googleapis.
the class TestBigtableTable method projectIsPopulatedInMutationRequests.
@Test
public void projectIsPopulatedInMutationRequests() throws IOException {
doAnswer(new Answer<ApiFuture<Void>>() {
@Override
public ApiFuture<Void> answer(InvocationOnMock invocationOnMock) {
return ApiFutures.immediateFuture(null);
}
}).when(mockBigtableDataClient).mutateRowAsync(Mockito.<RowMutation>any());
table.delete(new Delete(Bytes.toBytes("rowKey1")));
ArgumentCaptor<RowMutation> argument = ArgumentCaptor.forClass(RowMutation.class);
verify(mockBigtableDataClient).mutateRowAsync(argument.capture());
Assert.assertEquals("projects/testproject/instances/testinstance/tables/testtable", argument.getValue().toProto(REQUEST_CONTEXT).getTableName());
}
Aggregations