use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable-hbase by googleapis.
the class ColumnDescriptorAdapter method adapt.
/**
* Convert a Bigtable {@link com.google.cloud.bigtable.admin.v2.models.ColumnFamily} to an HBase
* {@link HColumnDescriptor}. See {@link #convertGarbageCollectionRule(GcRule, HColumnDescriptor)}
* for more info.
*
* @param columnFamily a {@link com.google.cloud.bigtable.admin.v2.models.ColumnFamily} object.
* @return a {@link org.apache.hadoop.hbase.HColumnDescriptor} object.
*/
public HColumnDescriptor adapt(com.google.cloud.bigtable.admin.v2.models.ColumnFamily columnFamily) {
HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(columnFamily.getId());
GCRule gcRule = columnFamily.getGCRule();
if (gcRule != null) {
convertGarbageCollectionRule(gcRule.toProto(), hColumnDescriptor);
}
return hColumnDescriptor;
}
use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable-hbase by googleapis.
the class TableAdapter method adapt.
/**
* adapt. This method adapts ColumnFamily to CreateTableRequest.
*
* @param desc a {@link HTableDescriptor} object.
* @param request a {@link CreateTableRequest}
*/
protected static void adapt(HTableDescriptor desc, CreateTableRequest request) {
if (request != null) {
for (HColumnDescriptor column : desc.getColumnFamilies()) {
String columnName = column.getNameAsString();
GCRule gcRule = buildGarbageCollectionRule(column);
if (gcRule == null) {
request.addFamily(columnName);
} else {
request.addFamily(columnName, gcRule);
}
}
}
}
use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable-hbase by googleapis.
the class TestColumnDescriptorAdapter method maxVersionsIsPreservedInColumnFamily.
@Test
public void maxVersionsIsPreservedInColumnFamily() {
GCRules.GCRule expected = GCRULES.maxVersions(10);
HColumnDescriptor descriptor = adapter.adapt(columnFamily(expected));
Assert.assertEquals(10, descriptor.getMaxVersions());
}
use of com.google.cloud.bigtable.admin.v2.models.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.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable-hbase by googleapis.
the class TestColumnDescriptorAdapter method testAdaptWithColumnFamilyForMaxAge.
@Test
public void testAdaptWithColumnFamilyForMaxAge() {
int ttl = 86400;
GCRule maxAgeGCRule = GCRULES.maxAge(Duration.ofSeconds(ttl));
HColumnDescriptor actual = adapter.adapt(columnFamily(maxAgeGCRule));
Assert.assertEquals(ttl, actual.getTimeToLive());
}
Aggregations