Search in sources :

Example 1 with GcRule

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

the class ColumnDescriptorAdapter method adapt.

/**
 * Adapt a single instance of an HBase {@link org.apache.hadoop.hbase.HColumnDescriptor} to an
 * instance of {@link com.google.bigtable.admin.v2.ColumnFamily.Builder}.
 *
 * <p>NOTE: This method does not set the name of the ColumnFamily.Builder. The assumption is that
 * the CreateTableRequest or CreateColumnFamilyRequest takes care of the naming. As of now
 * (3/11/2015), the server insists on having a blank name.
 *
 * @param columnDescriptor a {@link org.apache.hadoop.hbase.HColumnDescriptor} object.
 * @return a {@link com.google.bigtable.admin.v2.ColumnFamily.Builder} object.
 */
public ColumnFamily adapt(HColumnDescriptor columnDescriptor) {
    throwIfRequestingUnknownFeatures(columnDescriptor);
    throwIfRequestingUnsupportedFeatures(columnDescriptor);
    ColumnFamily.Builder resultBuilder = ColumnFamily.newBuilder();
    GCRule gcRule = buildGarbageCollectionRule(columnDescriptor);
    if (gcRule != null) {
        resultBuilder.setGcRule(gcRule.toProto());
    }
    return resultBuilder.build();
}
Also used : GCRule(com.google.cloud.bigtable.admin.v2.models.GCRules.GCRule) ColumnFamily(com.google.bigtable.admin.v2.ColumnFamily)

Example 2 with GcRule

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

the class GCRulesTest method intersectionThree.

@Test
public void intersectionThree() {
    GcRule actual = GCRULES.intersection().rule(GCRULES.maxVersions(1)).rule(GCRULES.maxAge(Duration.ofSeconds(1))).rule(GCRULES.maxAge(Duration.ofNanos(1))).toProto();
    GcRule expected = GcRule.newBuilder().setIntersection(Intersection.newBuilder().addRules(buildVersionsRule(1)).addRules(buildAgeRule(1, 0)).addRules(buildAgeRule(0, 1))).build();
    assertThat(actual).isEqualTo(expected);
}
Also used : GcRule(com.google.bigtable.admin.v2.GcRule) Test(org.junit.Test)

Example 3 with GcRule

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

the class GCRulesTest method duration.

@Test
public void duration() {
    DurationRule actual = GCRULES.maxAge(Duration.ofSeconds(61, 9));
    GcRule expected = buildAgeRule(61, 9);
    assertNotNull(actual.getMaxAge());
    assertThat(actual.toProto()).isEqualTo(expected);
}
Also used : GcRule(com.google.bigtable.admin.v2.GcRule) DurationRule(com.google.cloud.bigtable.admin.v2.models.GCRules.DurationRule) Test(org.junit.Test)

Example 4 with GcRule

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

the class GCRulesTest method unionTwo.

@Test
public void unionTwo() {
    GcRule actual = GCRULES.union().rule(GCRULES.maxVersions(1)).rule(GCRULES.maxAge(Duration.ofSeconds(1))).toProto();
    GcRule expected = GcRule.newBuilder().setUnion(Union.newBuilder().addRules(buildVersionsRule(1)).addRules(buildAgeRule(1, 0))).build();
    assertThat(actual).isEqualTo(expected);
}
Also used : GcRule(com.google.bigtable.admin.v2.GcRule) Test(org.junit.Test)

Example 5 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)

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