Search in sources :

Example 11 with ColumnFamily

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

the class TestColumnDescriptorAdapter method ttlIsPreservedInColumnFamily.

@Test
public void ttlIsPreservedInColumnFamily() {
    // TTL of 1 day (in microseconds):
    GCRules.GCRule expected = GCRULES.union().rule(GCRULES.maxAge(Duration.ofSeconds(86400))).rule(GCRULES.maxVersions(1));
    HColumnDescriptor descriptor = adapter.adapt(columnFamily(expected));
    Assert.assertEquals(1, descriptor.getMaxVersions());
    Assert.assertEquals(86400, descriptor.getTimeToLive());
}
Also used : GCRule(com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule) GCRules(com.google.cloud.bigtable.admin.v2.models.GCRules) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) Test(org.junit.Test)

Example 12 with ColumnFamily

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

the class TestColumnDescriptorAdapter method maxVersionsIsPreservedInGcExpression.

@Test
public void maxVersionsIsPreservedInGcExpression() {
    descriptor.setMaxVersions(10);
    ColumnFamily result = adapter.adapt(descriptor);
    GCRules.GCRule expected = GCRULES.maxVersions(10);
    Assert.assertEquals(expected.toProto(), result.getGcRule());
}
Also used : GCRule(com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule) GCRules(com.google.cloud.bigtable.admin.v2.models.GCRules) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) Test(org.junit.Test)

Example 13 with ColumnFamily

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

the class TestTableAdapter method testAdaptForTable.

@Test
public void testAdaptForTable() {
    // If no GcRule passed to ColumnFamily, then ColumnDescriptorAdapter#buildGarbageCollectionRule
    // updates maxVersion to Integer.MAX_VALUE
    GCRule gcRule = GCRULES.maxVersions(1);
    ColumnFamily columnFamily = ColumnFamily.newBuilder().setGcRule(gcRule.toProto()).build();
    Table table = Table.newBuilder().setName(TABLE_NAME).putColumnFamilies(COLUMN_FAMILY, columnFamily).build();
    HTableDescriptor actualTableDesc = TableAdapter.adapt(com.google.cloud.bigtable.admin.v2.models.Table.fromProto(table));
    HTableDescriptor expected = new HTableDescriptor(TableName.valueOf(TABLE_ID));
    expected.addFamily(new HColumnDescriptor(COLUMN_FAMILY));
    Assert.assertEquals(expected, actualTableDesc);
}
Also used : Table(com.google.bigtable.admin.v2.Table) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) GCRule(com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) Test(org.junit.Test)

Example 14 with ColumnFamily

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

the class TestTableAdapter2x method testAdaptWithTable.

@Test
public void testAdaptWithTable() {
    // If no GcRule passed to ColumnFamily, then ColumnDescriptorAdapter#buildGarbageCollectionRule
    // updates maxVersion to Integer.MAX_VALUE
    int maxVersion = 1;
    GCRules.GCRule gcRule = GCRULES.maxVersions(maxVersion);
    ColumnFamily columnFamily = ColumnFamily.newBuilder().setGcRule(gcRule.toProto()).build();
    Table table = Table.newBuilder().setName(TABLE_NAME).putColumnFamilies(COLUMN_FAMILY, columnFamily).build();
    TableDescriptor actualTableDesc = TableAdapter2x.adapt(com.google.cloud.bigtable.admin.v2.models.Table.fromProto(table));
    TableDescriptor expected = new HTableDescriptor(TableName.valueOf(TABLE_ID)).addFamily(new HColumnDescriptor(COLUMN_FAMILY));
    Assert.assertEquals(expected, actualTableDesc);
}
Also used : GCRules(com.google.cloud.bigtable.admin.v2.models.GCRules) Table(com.google.bigtable.admin.v2.Table) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) Test(org.junit.Test)

Example 15 with ColumnFamily

use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable by googleapis.

the class TableAdminExampleTest method ruleCheck.

// TODO: add test for tableAdmin.listAllTables()
// TODO: add test for tableAdmin.getTableMeta()
// TODO: add test for tableAdmin.listColumnFamilies()
private boolean ruleCheck(GCRule condition) {
    boolean found = false;
    List<ColumnFamily> columnFamilies = adminClient.getTable(tableId).getColumnFamilies();
    for (ColumnFamily columnFamily : columnFamilies) {
        if (columnFamily.getGCRule().equals(condition)) {
            found = true;
            break;
        }
    }
    return found;
}
Also used : ColumnFamily(com.google.cloud.bigtable.admin.v2.models.ColumnFamily)

Aggregations

Test (org.junit.Test)11 GCRule (com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule)10 ColumnFamily (com.google.cloud.bigtable.admin.v2.models.ColumnFamily)7 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)7 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)6 GCRules (com.google.cloud.bigtable.admin.v2.models.GCRules)5 Table (com.google.cloud.bigtable.admin.v2.models.Table)5 NotFoundException (com.google.api.gax.rpc.NotFoundException)3 ByteString (com.google.protobuf.ByteString)3 Table (com.google.bigtable.admin.v2.Table)2 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)2 CreateTableRequest (com.google.cloud.bigtable.admin.v2.models.CreateTableRequest)1 DurationRule (com.google.cloud.bigtable.admin.v2.models.GCRules.DurationRule)1 IntersectionRule (com.google.cloud.bigtable.admin.v2.models.GCRules.IntersectionRule)1 UnionRule (com.google.cloud.bigtable.admin.v2.models.GCRules.UnionRule)1 VersionRule (com.google.cloud.bigtable.admin.v2.models.GCRules.VersionRule)1 ModifyColumnFamiliesRequest (com.google.cloud.bigtable.admin.v2.models.ModifyColumnFamiliesRequest)1 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)1