Search in sources :

Example 31 with BigtableDataClient

use of com.google.cloud.bigtable.data.v2.BigtableDataClient in project java-bigtable by googleapis.

the class MobileTimeSeriesBaseTest method writePlanData.

public static void writePlanData() throws IOException {
    try (BigtableDataClient dataClient = BigtableDataClient.create(projectId, instanceId)) {
        BulkMutation bulkMutation = BulkMutation.create(TABLE_ID).add("phone#4c410523#20190501", Mutation.create().setCell(COLUMN_FAMILY_NAME_PLAN, "data_plan_01gb", TIMESTAMP_MINUS_HR, "true").setCell(COLUMN_FAMILY_NAME_PLAN, "data_plan_01gb", TIMESTAMP, "false").setCell(COLUMN_FAMILY_NAME_PLAN, "data_plan_05gb", TIMESTAMP, "true")).add("phone#4c410523#20190502", Mutation.create().setCell(COLUMN_FAMILY_NAME_PLAN, "data_plan_05gb", TIMESTAMP, "true")).add("phone#4c410523#20190505", Mutation.create().setCell(COLUMN_FAMILY_NAME_PLAN, "data_plan_05gb", TIMESTAMP, "true")).add("phone#5c10102#20190501", Mutation.create().setCell(COLUMN_FAMILY_NAME_PLAN, "data_plan_10gb", TIMESTAMP, "true")).add("phone#5c10102#20190502", Mutation.create().setCell(COLUMN_FAMILY_NAME_PLAN, "data_plan_10gb", TIMESTAMP, "true"));
        dataClient.bulkMutateRows(bulkMutation);
    } catch (IOException e) {
        System.out.println("Error during writeTestData: \n" + e.toString());
        throw (e);
    }
}
Also used : BulkMutation(com.google.cloud.bigtable.data.v2.models.BulkMutation) IOException(java.io.IOException) BigtableDataClient(com.google.cloud.bigtable.data.v2.BigtableDataClient)

Aggregations

BigtableDataClient (com.google.cloud.bigtable.data.v2.BigtableDataClient)27 Row (com.google.cloud.bigtable.data.v2.models.Row)18 IOException (java.io.IOException)13 Query (com.google.cloud.bigtable.data.v2.models.Query)8 BulkMutation (com.google.cloud.bigtable.data.v2.models.BulkMutation)7 ByteString (com.google.protobuf.ByteString)7 Test (org.junit.Test)6 BigtableTableAdminClient (com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient)4 BigtableDataSettings (com.google.cloud.bigtable.data.v2.BigtableDataSettings)4 CreateTableRequest (com.google.cloud.bigtable.admin.v2.models.CreateTableRequest)3 RowCell (com.google.cloud.bigtable.data.v2.models.RowCell)3 RowMutation (com.google.cloud.bigtable.data.v2.models.RowMutation)3 RowMutationEntry (com.google.cloud.bigtable.data.v2.models.RowMutationEntry)3 BeforeClass (org.junit.BeforeClass)3 ApiFuture (com.google.api.core.ApiFuture)2 Filters (com.google.cloud.bigtable.data.v2.models.Filters)2 ReadModifyWriteRow (com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow)2 ArrayList (java.util.ArrayList)2 BatcherImpl (com.google.api.gax.batching.BatcherImpl)1 FlowControlEventStats (com.google.api.gax.batching.FlowControlEventStats)1