Search in sources :

Example 6 with ColumnFamily

use of com.google.bigtable.admin.v2.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 7 with ColumnFamily

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

the class TestColumnDescriptorAdapter method testGCruleMaxVersion.

@Test
public void testGCruleMaxVersion() {
    int ttl = 100;
    descriptor.setTimeToLive(ttl);
    descriptor.setMaxVersions(Integer.MAX_VALUE);
    ColumnFamily result = adapter.adapt(descriptor);
    GCRule expected = GCRULES.maxAge(Duration.ofSeconds(ttl));
    Assert.assertEquals(expected.toProto(), result.getGcRule());
}
Also used : GCRule(com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) Test(org.junit.Test)

Example 8 with ColumnFamily

use of com.google.bigtable.admin.v2.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 9 with ColumnFamily

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

the class TestColumnDescriptorAdapter method minMaxTtlInDescriptor.

@Test
public void minMaxTtlInDescriptor() {
    descriptor.setMaxVersions(20);
    descriptor.setMinVersions(10);
    // 1 day in seconds
    descriptor.setTimeToLive(86400);
    ColumnFamily result = adapter.adapt(descriptor);
    Assert.assertEquals(minMaxRule(10, 86400, 20).toProto(), result.getGcRule());
}
Also used : ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily) Test(org.junit.Test)

Example 10 with ColumnFamily

use of com.google.bigtable.admin.v2.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)

Aggregations

ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)19 Test (org.junit.Test)18 Table (com.google.bigtable.admin.v2.Table)13 AbstractMessage (com.google.protobuf.AbstractMessage)11 ByteString (com.google.protobuf.ByteString)11 HashMap (java.util.HashMap)11 GCRule (com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule)5 Operation (com.google.longrunning.Operation)5 CreateTableFromSnapshotRequest (com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest)4 InstanceName (com.google.bigtable.admin.v2.InstanceName)3 TableName (com.google.bigtable.admin.v2.TableName)3 GCRules (com.google.cloud.bigtable.admin.v2.models.GCRules)3 CreateTableRequest (com.google.bigtable.admin.v2.CreateTableRequest)2 GetTableRequest (com.google.bigtable.admin.v2.GetTableRequest)2 ModifyColumnFamiliesRequest (com.google.bigtable.admin.v2.ModifyColumnFamiliesRequest)2 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)2 ArrayList (java.util.ArrayList)2 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)2 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)2 RestoreTableRequest (com.google.bigtable.admin.v2.RestoreTableRequest)1