use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable by googleapis.
the class TableAdminExample method listColumnFamilies.
/**
* Demonstrates how to list a table's column families.
*/
public void listColumnFamilies() {
System.out.println("\nPrinting ID and GC Rule for all column families");
// Lists all families in the table with GC rules.
try {
Table table = adminClient.getTable(tableId);
Collection<ColumnFamily> columnFamilies = table.getColumnFamilies();
for (ColumnFamily columnFamily : columnFamilies) {
System.out.printf("Column family: %s%nGC Rule: %s%n", columnFamily.getId(), columnFamily.getGCRule().toString());
}
} catch (NotFoundException e) {
System.err.println("Failed to list column families from a non-existent table: " + e.getMessage());
}
// [END bigtable_list_column_families]
}
use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable by googleapis.
the class TableAdminExample method printModifiedColumnFamily.
/**
* Demonstrates how to print the modified column family.
*/
public void printModifiedColumnFamily() {
System.out.printf("%nPrint updated GC rule for column family %s%n", COLUMN_FAMILY_1);
// [START bigtable_family_get_gc_rule]
try {
Table table = adminClient.getTable(tableId);
Collection<ColumnFamily> columnFamilies = table.getColumnFamilies();
for (ColumnFamily columnFamily : columnFamilies) {
if (columnFamily.getId().equals(COLUMN_FAMILY_1)) {
System.out.printf("Column family: %s%nGC Rule: %s%n", columnFamily.getId(), columnFamily.getGCRule().toString());
}
}
} catch (NotFoundException e) {
System.err.println("Failed to print a non-existent column family: " + e.getMessage());
}
// [END bigtable_family_get_gc_rule]
}
use of com.google.cloud.bigtable.admin.v2.models.ColumnFamily in project java-bigtable by googleapis.
the class TableAdminExampleTest method testCreateMaxVersionsRuleAndDeleteColumnFamily.
@Test
public void testCreateMaxVersionsRuleAndDeleteColumnFamily() {
// Max versions rule
tableAdmin.addFamilyWithMaxVersionsRule();
VersionRule maxVersionCondition = GCRULES.maxVersions(2);
boolean maxVersionRule = ruleCheck(maxVersionCondition);
assertTrue(maxVersionRule);
// Deletes cf2.
tableAdmin.deleteColumnFamily();
boolean found = true;
List<ColumnFamily> columnFamilies = adminClient.getTable(tableId).getColumnFamilies();
for (ColumnFamily columnFamily : columnFamilies) {
if (columnFamily.equals("cf2")) {
found = false;
break;
}
}
assertTrue(found);
}
Aggregations