Search in sources :

Example 21 with RowMutation

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;
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation)

Example 22 with 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");
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) ConditionalRowMutation(com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation)

Example 23 with RowMutation

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();
}
Also used : MutateRowRequest(com.google.bigtable.v2.MutateRowRequest) RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation)

Example 24 with RowMutation

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());
}
Also used : MutateRowRequest(com.google.bigtable.v2.MutateRowRequest) SetCell(com.google.bigtable.v2.Mutation.SetCell) RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) Mutation(com.google.bigtable.v2.Mutation) RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) Put(org.apache.hadoop.hbase.client.Put) Test(org.junit.Test)

Example 25 with RowMutation

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());
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) ApiFuture(com.google.api.core.ApiFuture) InvocationOnMock(org.mockito.invocation.InvocationOnMock) RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) Test(org.junit.Test)

Aggregations

RowMutation (com.google.cloud.bigtable.data.v2.models.RowMutation)23 ByteString (com.google.protobuf.ByteString)8 Test (org.junit.Test)7 ConditionalRowMutation (com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation)5 RowMutationEntry (com.google.cloud.bigtable.data.v2.models.RowMutationEntry)5 MutateRowRequest (com.google.bigtable.v2.MutateRowRequest)3 ApiFuture (com.google.api.core.ApiFuture)2 UnaryCallable (com.google.api.gax.rpc.UnaryCallable)2 BigtableDataClient (com.google.cloud.bigtable.data.v2.BigtableDataClient)2 ApiFutures (com.google.api.core.ApiFutures)1 Batcher (com.google.api.gax.batching.Batcher)1 BatcherImpl (com.google.api.gax.batching.BatcherImpl)1 BatchingDescriptor (com.google.api.gax.batching.BatchingDescriptor)1 BatchingSettings (com.google.api.gax.batching.BatchingSettings)1 FlowControlSettings (com.google.api.gax.batching.FlowControlSettings)1 NotFoundException (com.google.api.gax.rpc.NotFoundException)1 ResponseObserver (com.google.api.gax.rpc.ResponseObserver)1 ServerStreamingCallable (com.google.api.gax.rpc.ServerStreamingCallable)1 CheckAndMutateRowRequest (com.google.bigtable.v2.CheckAndMutateRowRequest)1 CheckAndMutateRowResponse (com.google.bigtable.v2.CheckAndMutateRowResponse)1