use of com.google.cloud.bigtable.admin.v2.models.CreateTableRequest in project java-bigtable-hbase by googleapis.
the class TestTableAdapter2x method testAdaptWithSplitKeys.
@Test
public void testAdaptWithSplitKeys() {
byte[][] splits = new byte[][] { Bytes.toBytes("AAA"), Bytes.toBytes("BBB"), Bytes.toBytes("CCC") };
TableDescriptor desc = TableDescriptorBuilder.newBuilder(TableName.valueOf(TABLE_ID)).build();
CreateTableRequest actualRequest = TableAdapter2x.adapt(desc, splits);
CreateTableRequest expectedRequest = CreateTableRequest.of(TABLE_ID);
TableAdapter.addSplitKeys(splits, expectedRequest);
Assert.assertEquals(expectedRequest.toProto(PROJECT_ID, INSTANCE_ID), actualRequest.toProto(PROJECT_ID, INSTANCE_ID));
}
use of com.google.cloud.bigtable.admin.v2.models.CreateTableRequest in project java-bigtable by googleapis.
the class BigtableTableAdminClientTest method testCreateTable.
@Test
public void testCreateTable() {
// Setup
Mockito.when(mockStub.createTableCallable()).thenReturn(mockCreateTableCallable);
com.google.bigtable.admin.v2.CreateTableRequest expectedRequest = com.google.bigtable.admin.v2.CreateTableRequest.newBuilder().setParent(INSTANCE_NAME).setTableId(TABLE_ID).build();
com.google.bigtable.admin.v2.Table expectedResponse = com.google.bigtable.admin.v2.Table.newBuilder().setName(TABLE_NAME).build();
Mockito.when(mockCreateTableCallable.futureCall(expectedRequest)).thenReturn(ApiFutures.immediateFuture(expectedResponse));
// Execute
Table result = adminClient.createTable(CreateTableRequest.of(TABLE_ID));
// Verify
assertThat(result).isEqualTo(Table.fromProto(expectedResponse));
}
use of com.google.cloud.bigtable.admin.v2.models.CreateTableRequest in project java-bigtable by googleapis.
the class MobileTimeSeriesBaseTest method createTable.
public static void createTable() throws IOException {
try (BigtableTableAdminClient adminClient = BigtableTableAdminClient.create(projectId, instanceId)) {
CreateTableRequest createTableRequest = CreateTableRequest.of(TABLE_ID).addFamily(COLUMN_FAMILY_NAME_STATS).addFamily(COLUMN_FAMILY_NAME_PLAN);
adminClient.createTable(createTableRequest);
} catch (IOException e) {
System.out.println("Error during createTable: \n" + e.toString());
throw (e);
}
}
use of com.google.cloud.bigtable.admin.v2.models.CreateTableRequest in project java-bigquery by googleapis.
the class QueryExternalBigtableTempIT method setUp.
@Before
public void setUp() throws IOException {
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);
// create a temporary bigtable table.
try (BigtableTableAdminClient client = BigtableTableAdminClient.create(PROJECT, INSTANCE)) {
CreateTableRequest createTableRequest = CreateTableRequest.of(TABLE_ID).addFamily(COLUMN_FAMILY_NAME);
client.createTable(createTableRequest);
}
// inserting temporary rows.
try (BigtableDataClient client = BigtableDataClient.create(PROJECT, INSTANCE)) {
BulkMutation bulkMutation = BulkMutation.create(TABLE_ID).add("phone#4c410523#20190501", Mutation.create().setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_CELL.getBytes()), TIMESTAMP, 1).setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_WIFI.getBytes()), TIMESTAMP, 1).setCell(COLUMN_FAMILY_NAME, OS_BUILD, TIMESTAMP, "PQ2A.190405.003")).add("phone#4c410523#20190502", Mutation.create().setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_CELL.getBytes()), TIMESTAMP, 1).setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_WIFI.getBytes()), TIMESTAMP, 1).setCell(COLUMN_FAMILY_NAME, OS_BUILD, TIMESTAMP, "PQ2A.190405.004")).add("phone#4c410523#20190505", Mutation.create().setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_CELL.getBytes()), TIMESTAMP, 0).setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_WIFI.getBytes()), TIMESTAMP, 1).setCell(COLUMN_FAMILY_NAME, OS_BUILD, TIMESTAMP, "PQ2A.190406.000")).add("phone#5c10102#20190501", Mutation.create().setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_CELL.getBytes()), TIMESTAMP, 1).setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_WIFI.getBytes()), TIMESTAMP, 1).setCell(COLUMN_FAMILY_NAME, OS_BUILD, TIMESTAMP, "PQ2A.190401.002")).add("phone#5c10102#20190502", Mutation.create().setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_CELL.getBytes()), TIMESTAMP, 1).setCell(COLUMN_FAMILY_NAME, ByteString.copyFrom(CONNECTED_WIFI.getBytes()), TIMESTAMP, 0).setCell(COLUMN_FAMILY_NAME, OS_BUILD, TIMESTAMP, "PQ2A.190406.000"));
client.bulkMutateRows(bulkMutation);
}
}
Aggregations