Search in sources :

Example 1 with Row

use of com.google.cloud.bigtable.data.v2.models.Row in project java-docs-samples by GoogleCloudPlatform.

the class CassandraMigrationCodelab method get.

public void get() {
    try {
        String rowKey = "phone#4c410523#20190501";
        Row row = dataClient.readRow(tableId, rowKey);
        for (RowCell cell : row.getCells()) {
            System.out.printf("Family: %s    Qualifier: %s    Value: %s    Timestamp: %s%n", cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8(), cell.getTimestamp());
        }
    } catch (Exception e) {
        System.out.println("Error during lookup: \n" + e.toString());
    }
}
Also used : RowCell(com.google.cloud.bigtable.data.v2.models.RowCell) ByteString(com.google.protobuf.ByteString) Row(com.google.cloud.bigtable.data.v2.models.Row)

Example 2 with Row

use of com.google.cloud.bigtable.data.v2.models.Row in project java-docs-samples by GoogleCloudPlatform.

the class CassandraMigrationCodelab method scan.

public void scan() {
    try {
        Query query = Query.create(tableId).range("tablet#a0b81f74#201905", "tablet#a0b81f74#201906");
        ServerStream<Row> rowStream = dataClient.readRows(query);
        for (Row row : rowStream) {
            System.out.println("Row Key: " + row.getKey().toStringUtf8());
            for (RowCell cell : row.getCells()) {
                System.out.printf("Family: %s    Qualifier: %s    Value: %s    Timestamp: %s%n", cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8(), cell.getTimestamp());
            }
        }
    } catch (Exception e) {
        System.out.println("Error during scan: \n" + e.toString());
    }
}
Also used : Query(com.google.cloud.bigtable.data.v2.models.Query) RowCell(com.google.cloud.bigtable.data.v2.models.RowCell) Row(com.google.cloud.bigtable.data.v2.models.Row)

Example 3 with Row

use of com.google.cloud.bigtable.data.v2.models.Row in project testcontainers-java by testcontainers.

the class BigtableEmulatorContainerTest method testSimple.

// }
@Test
public // testWithEmulatorContainer {
void testSimple() throws IOException, InterruptedException, ExecutionException {
    ManagedChannel channel = ManagedChannelBuilder.forTarget(emulator.getEmulatorEndpoint()).usePlaintext().build();
    TransportChannelProvider channelProvider = FixedTransportChannelProvider.create(GrpcTransportChannel.create(channel));
    NoCredentialsProvider credentialsProvider = NoCredentialsProvider.create();
    try {
        createTable(channelProvider, credentialsProvider, "test-table");
        BigtableDataClient client = BigtableDataClient.create(BigtableDataSettings.newBuilderForEmulator(emulator.getHost(), emulator.getEmulatorPort()).setProjectId(PROJECT_ID).setInstanceId(INSTANCE_ID).build());
        client.mutateRow(RowMutation.create("test-table", "1").setCell("name", "firstName", "Ray"));
        Row row = client.readRow("test-table", "1");
        List<RowCell> cells = row.getCells("name", "firstName");
        assertThat(cells).isNotNull().hasSize(1);
        assertThat(cells.get(0).getValue().toStringUtf8()).isEqualTo("Ray");
    } finally {
        channel.shutdown();
    }
}
Also used : NoCredentialsProvider(com.google.api.gax.core.NoCredentialsProvider) ManagedChannel(io.grpc.ManagedChannel) RowCell(com.google.cloud.bigtable.data.v2.models.RowCell) Row(com.google.cloud.bigtable.data.v2.models.Row) FixedTransportChannelProvider(com.google.api.gax.rpc.FixedTransportChannelProvider) TransportChannelProvider(com.google.api.gax.rpc.TransportChannelProvider) BigtableDataClient(com.google.cloud.bigtable.data.v2.BigtableDataClient) Test(org.junit.Test)

Example 4 with Row

use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable-hbase by googleapis.

the class AbstractBigtableTable method checkAndDelete.

/**
 * {@inheritDoc}
 */
@Override
public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException {
    LOG.trace("checkAndDelete(byte[], byte[], byte[], CompareOp, byte[], Delete)");
    ConditionalRowMutation request = new CheckAndMutateUtil.RequestBuilder(hbaseAdapter, row, family).qualifier(qualifier).ifMatches(compareOp, value).withDelete(delete).build();
    return checkAndMutate(row, request, "checkAndDelete");
}
Also used : ConditionalRowMutation(com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation)

Example 5 with Row

use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable-hbase by googleapis.

the class ColumnPaginationFilterAdapter method createChain.

/**
 * Create a filter chain that allows the latest values for each qualifier, those cells that pass
 * an option intermediate filter and are less than the limit per row.
 */
private Filter createChain(ColumnPaginationFilter filter, Filter intermediate) {
    ChainFilter chain = FILTERS.chain();
    chain.filter(FILTERS.limit().cellsPerColumn(1));
    if (intermediate != null) {
        chain.filter(intermediate);
    }
    chain.filter(FILTERS.limit().cellsPerRow(filter.getLimit()));
    return chain;
}
Also used : ChainFilter(com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter)

Aggregations

Row (com.google.cloud.bigtable.data.v2.models.Row)59 Test (org.junit.Test)51 Query (com.google.cloud.bigtable.data.v2.models.Query)28 ByteString (com.google.protobuf.ByteString)25 BigtableDataClient (com.google.cloud.bigtable.data.v2.BigtableDataClient)18 ReadModifyWriteRow (com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow)16 RowCell (com.google.cloud.bigtable.data.v2.models.RowCell)15 ReadRowsRequest (com.google.bigtable.v2.ReadRowsRequest)12 IOException (java.io.IOException)10 Filter (com.google.cloud.bigtable.data.v2.models.Filters.Filter)7 RowMutation (com.google.cloud.bigtable.data.v2.models.RowMutation)7 ServerStreamingStashCallable (com.google.cloud.bigtable.gaxx.testing.FakeStreamingApi.ServerStreamingStashCallable)7 Put (org.apache.hadoop.hbase.client.Put)7 DefaultRowAdapter (com.google.cloud.bigtable.data.v2.models.DefaultRowAdapter)6 MutateRowRequest (com.google.bigtable.v2.MutateRowRequest)5 Mutation (com.google.bigtable.v2.Mutation)5 SetCell (com.google.bigtable.v2.Mutation.SetCell)5 NotFoundException (com.google.api.gax.rpc.NotFoundException)4 ConditionalRowMutation (com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation)4 RowMutationEntry (com.google.cloud.bigtable.data.v2.models.RowMutationEntry)4