Search in sources :

Example 16 with CreateTableRequest

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));
}
Also used : CreateTableRequest(com.google.cloud.bigtable.admin.v2.models.CreateTableRequest) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) Test(org.junit.Test)

Example 17 with CreateTableRequest

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));
}
Also used : Table(com.google.cloud.bigtable.admin.v2.models.Table) Test(org.junit.Test)

Example 18 with CreateTableRequest

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);
    }
}
Also used : BigtableTableAdminClient(com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient) IOException(java.io.IOException) CreateTableRequest(com.google.cloud.bigtable.admin.v2.models.CreateTableRequest)

Example 19 with CreateTableRequest

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);
    }
}
Also used : BulkMutation(com.google.cloud.bigtable.data.v2.models.BulkMutation) PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) 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) Before(org.junit.Before)

Aggregations

CreateTableRequest (com.google.cloud.bigtable.admin.v2.models.CreateTableRequest)16 Test (org.junit.Test)7 BigtableTableAdminClient (com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient)6 BigtableDataClient (com.google.cloud.bigtable.data.v2.BigtableDataClient)5 Table (com.google.cloud.bigtable.admin.v2.models.Table)4 BulkMutation (com.google.cloud.bigtable.data.v2.models.BulkMutation)4 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)4 GCRule (com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule)3 IOException (java.io.IOException)3 BeforeClass (org.junit.BeforeClass)3 ByteString (com.google.protobuf.ByteString)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintStream (java.io.PrintStream)2 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)2 Before (org.junit.Before)2 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)1 ColumnFamily (com.google.cloud.bigtable.admin.v2.models.ColumnFamily)1 RowMutation (com.google.cloud.bigtable.data.v2.models.RowMutation)1 ArrayList (java.util.ArrayList)1 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)1