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);
}
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());
}
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());
}
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());
}
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);
}
Aggregations