Search in sources :

Example 1 with RowMutation

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

the class CassandraMigrationCodelab method update.

public void update() {
    try {
        // Timestamp of June 1, 2019 12:30
        long timestamp = (long) 1556713800 * 1000;
        String rowKey = "phone#4c410523#20190501";
        RowMutation rowMutation = RowMutation.create(tableId, rowKey).setCell(COLUMN_FAMILY_NAME, "os_name", timestamp, "android");
        dataClient.mutateRow(rowMutation);
    } catch (Exception e) {
        System.out.println("Error during update: \n" + e.toString());
    }
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) ByteString(com.google.protobuf.ByteString)

Example 2 with RowMutation

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

the class CassandraMigrationCodelab method delete.

public void delete() {
    try {
        String rowKey = "phone#4c410523#20190501";
        RowMutation mutation = RowMutation.create(tableId, rowKey).deleteRow();
        dataClient.mutateRow(mutation);
    } catch (Exception e) {
        System.out.println("Error during Delete: \n" + e.toString());
    }
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) ByteString(com.google.protobuf.ByteString)

Example 3 with RowMutation

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

the class CassandraMigrationCodelab method write.

public void write() {
    try {
        System.currentTimeMillis();
        // Timestamp of June 1, 2019 12:00
        long timestamp = (long) 1556712000 * 1000;
        String rowKey = "phone#4c410523#20190501";
        ByteString one = ByteString.copyFrom(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 });
        RowMutation rowMutation = RowMutation.create(tableId, rowKey).setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom("connected_cell".getBytes()), timestamp, one).setCell(COLUMN_FAMILY_NAME, "os_build", timestamp, "PQ2A.190405.003");
        dataClient.mutateRow(rowMutation);
    } catch (Exception e) {
        System.out.println("Error during Write: \n" + e.toString());
    }
}
Also used : ByteString(com.google.protobuf.ByteString) RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) ByteString(com.google.protobuf.ByteString)

Example 4 with RowMutation

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

the class MemcachedTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    projectId = requireEnv("GOOGLE_CLOUD_PROJECT");
    instanceId = requireEnv(INSTANCE_ENV);
    try (BigtableTableAdminClient adminClient = BigtableTableAdminClient.create(projectId, instanceId)) {
        CreateTableRequest createTableRequest = CreateTableRequest.of(TABLE_ID).addFamily(COLUMN_FAMILY_NAME);
        adminClient.createTable(createTableRequest);
        try (BigtableDataClient dataClient = BigtableDataClient.create(projectId, instanceId)) {
            String rowkey = "phone#4c410523#20190501";
            RowMutation rowMutation = RowMutation.create(TABLE_ID, rowkey).setCell(COLUMN_FAMILY_NAME, "os_build", "PQ2A.190405.003");
            dataClient.mutateRow(rowMutation);
        }
        String[] dockerCommand = (String.format("docker run --name %s -itd --rm --publish 11211:11211 sameersbn/memcached:latest", MEMCACHED_CONTAINER_NAME)).split(" ");
        Process process = new ProcessBuilder(dockerCommand).start();
        process.waitFor();
    } catch (Exception e) {
        System.out.println("Error during beforeClass: \n" + e.toString());
    }
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) BigtableTableAdminClient(com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient) BigtableDataClient(com.google.cloud.bigtable.data.v2.BigtableDataClient) CreateTableRequest(com.google.cloud.bigtable.admin.v2.models.CreateTableRequest) BeforeClass(org.junit.BeforeClass)

Example 5 with RowMutation

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

the class AbstractBigtableTable method put.

/**
 * {@inheritDoc}
 */
@Override
public void put(Put put) throws IOException {
    LOG.trace("put(Put)");
    RowMutation rowMutation = hbaseAdapter.adapt(put);
    mutateRow(put, rowMutation, "put");
}
Also used : RowMutation(com.google.cloud.bigtable.data.v2.models.RowMutation) ConditionalRowMutation(com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation)

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