use of com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow in project java-bigtable-hbase by googleapis.
the class AbstractBigtableTable method increment.
/**
* {@inheritDoc}
*/
@Override
public Result increment(Increment increment) throws IOException {
LOG.trace("increment(Increment)");
Span span = TRACER.spanBuilder("BigtableTable.increment").startSpan();
try (Scope scope = TRACER.withSpan(span)) {
ReadModifyWriteRow request = hbaseAdapter.adapt(increment);
return FutureUtil.unwrap(clientWrapper.readModifyWriteRowAsync(request));
} catch (Throwable t) {
span.setStatus(Status.UNKNOWN);
throw logAndCreateIOException("increment", increment.getRow(), t);
} finally {
span.end();
}
}
use of com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow in project java-bigtable-hbase by googleapis.
the class HBaseRequestAdapter method adapt.
/**
* adapt.
*
* @param increment a {@link Increment} object.
* @return a {@link ReadModifyWriteRow} object.
*/
public ReadModifyWriteRow adapt(Increment increment) {
ReadModifyWriteRow readModifyWriteRow = ReadModifyWriteRow.create(getTableId(), ByteString.copyFrom(increment.getRow()));
Adapters.INCREMENT_ADAPTER.adapt(increment, readModifyWriteRow);
return readModifyWriteRow;
}
use of com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow in project java-bigtable-hbase by googleapis.
the class HBaseRequestAdapter method adapt.
/**
* adapt.
*
* @param append a {@link Append} object.
* @return a {@link ReadModifyWriteRow} object.
*/
public ReadModifyWriteRow adapt(Append append) {
ReadModifyWriteRow readModifyWriteRow = ReadModifyWriteRow.create(getTableId(), ByteString.copyFrom(append.getRow()));
Adapters.APPEND_ADAPTER.adapt(append, readModifyWriteRow);
return readModifyWriteRow;
}
use of com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow in project java-bigtable-hbase by googleapis.
the class TestAppendAdapter method testMultipleColumnFamiliesWithSameQualifiers.
@Test
public void testMultipleColumnFamiliesWithSameQualifiers() {
byte[] rowKey = dataHelper.randomData("rk1-");
byte[] family1 = Bytes.toBytes("family1");
byte[] qualifier1 = Bytes.toBytes("qualifier1");
byte[] value1 = Bytes.toBytes("value1");
byte[] family2 = Bytes.toBytes("family2");
byte[] value2 = Bytes.toBytes("value2");
Append append = new Append(rowKey);
append.add(family1, qualifier1, value1);
append.add(family2, qualifier1, value2);
ReadModifyWriteRow readModifyWriteRow = ReadModifyWriteRow.create(TABLE_ID, ByteString.copyFrom(rowKey));
appendAdapter.adapt(append, readModifyWriteRow);
ReadModifyWriteRowRequest request = readModifyWriteRow.toProto(requestContext);
List<ReadModifyWriteRule> rules = request.getRulesList();
Assert.assertEquals(2, rules.size());
Assert.assertEquals("family1", rules.get(0).getFamilyName());
Assert.assertEquals("qualifier1", rules.get(0).getColumnQualifier().toStringUtf8());
Assert.assertEquals("value1", rules.get(0).getAppendValue().toStringUtf8());
Assert.assertEquals("family2", rules.get(1).getFamilyName());
Assert.assertEquals("qualifier1", rules.get(1).getColumnQualifier().toStringUtf8());
// Value3 as it was added after value2:
Assert.assertEquals("value2", rules.get(1).getAppendValue().toStringUtf8());
}
use of com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow in project java-bigtable-hbase by googleapis.
the class TestAppendAdapter method testMultipleAppendsWithDuplicates.
@Test
public void testMultipleAppendsWithDuplicates() {
byte[] rowKey = dataHelper.randomData("rk1-");
byte[] family1 = Bytes.toBytes("family1");
byte[] qualifier1 = Bytes.toBytes("qualifier1");
byte[] value1 = Bytes.toBytes("value1");
byte[] family2 = Bytes.toBytes("family2");
byte[] qualifier2 = Bytes.toBytes("qualifier2");
byte[] value2 = Bytes.toBytes("value2");
byte[] value3 = Bytes.toBytes("value3");
Append append = new Append(rowKey);
append.add(family1, qualifier1, value1);
append.add(family2, qualifier2, value2);
append.add(family2, qualifier2, value3);
ReadModifyWriteRow readModifyWriteRow = ReadModifyWriteRow.create(TABLE_ID, ByteString.copyFrom(rowKey));
appendAdapter.adapt(append, readModifyWriteRow);
ReadModifyWriteRowRequest request = readModifyWriteRow.toProto(requestContext);
List<ReadModifyWriteRule> rules = request.getRulesList();
Assert.assertEquals(2, rules.size());
Assert.assertEquals("family1", rules.get(0).getFamilyName());
Assert.assertEquals("qualifier1", rules.get(0).getColumnQualifier().toStringUtf8());
Assert.assertEquals("value1", rules.get(0).getAppendValue().toStringUtf8());
Assert.assertEquals("family2", rules.get(1).getFamilyName());
Assert.assertEquals("qualifier2", rules.get(1).getColumnQualifier().toStringUtf8());
// Value3 as it was added after value2:
Assert.assertEquals("value3", rules.get(1).getAppendValue().toStringUtf8());
}
Aggregations