Search in sources :

Example 11 with GcRule

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

the class GCRulesTest method durationNanos.

@Test
public void durationNanos() {
    GcRule actual = GCRULES.maxAge(Duration.ofNanos(11)).toProto();
    GcRule expected = buildAgeRule(0, 11);
    assertThat(actual).isEqualTo(expected);
}
Also used : GcRule(com.google.bigtable.admin.v2.GcRule) Test(org.junit.Test)

Example 12 with GcRule

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

the class GCRulesTest method durationTimeUnitMinutes.

@Test
public void durationTimeUnitMinutes() {
    GcRule actual = GCRULES.maxAge(1, TimeUnit.MINUTES).toProto();
    GcRule expected = buildAgeRule(60, 0);
    assertThat(actual).isEqualTo(expected);
}
Also used : GcRule(com.google.bigtable.admin.v2.GcRule) Test(org.junit.Test)

Example 13 with GcRule

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

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

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

Test (org.junit.Test)24 GcRule (com.google.bigtable.admin.v2.GcRule)21 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)4 GCRule (com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule)3 Table (com.google.bigtable.admin.v2.Table)2 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)2 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)2 GCRules (com.google.cloud.bigtable.admin.v2.models.GCRules)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 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)1