Cloud Bigtable: tableAdmin sample#4313
Conversation
| // [START bigtable_list_tables] | ||
| // Lists tables in the current instance. | ||
| try { | ||
| List<String> listTables = adminClient.listTables(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| System.out.println("Table: " + table.getId()); | ||
| Collection<ColumnFamily> columnFamilies = table.getColumnFamilies(); | ||
| for (ColumnFamily columnFamily : columnFamilies) { | ||
| printColumnFamily(columnFamily); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| // where 1 = most recent version | ||
|
|
||
| // Defines the GC policy to retain only the most recent 2 versions. | ||
| GCRules.VersionRule versionRule1 = GCRules.GCRULES.maxVersions(2); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| /** Demonstrates how to create a new instance of the DurationRule. */ | ||
| public void maxAgeRule() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| GCRules.DurationRule maxAgeRule2 = GCRules.GCRULES.maxAge(5, TimeUnit.DAYS); | ||
| GCRules.VersionRule versionRule2 = GCRules.GCRULES.maxVersions(1); | ||
| // Add rules to union rule list | ||
| GCRules.UnionRule unionRule1 = GCRules.GCRULES.union().rule(maxAgeRule2).rule(versionRule2); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| ModifyColumnFamiliesRequest.of(tableId).addFamily(COLUMN_FAMILY_4, intersectionRule1); | ||
| adminClient.modifyFamilies(columnFamiliesRequest4); | ||
| System.out.println("Created column family: " + COLUMN_FAMILY_4); | ||
| } catch (AlreadyExistsException e) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| /** Demonstrates how to modify a column family's rule. */ | ||
| public void modifyColumnFamilyRule() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if (!matcher.matches()) { | ||
| continue; | ||
| } | ||
| System.out.println("\nGarbage collecting orphaned table: " + tableId); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| // TODO: add test for tableAdmin.getTableMeta() | ||
| // TODO: add test for tableAdmin.listColumnFamilies() | ||
|
|
||
| private boolean ruleCheck(Object condition) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
1f8a5c0 to
f72f1e2
Compare
| continue; | ||
| } | ||
| String timestampStr = matcher.group(1); | ||
| long timestamp = Long.parseLong(timestampStr); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
This is looking pretty good, will just need the TODO tests |
| return; | ||
| } | ||
| instanceName = InstanceName.parse(targetInstance).getInstance(); | ||
| projectName = InstanceName.parse(targetInstance).getProject(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
igorbernstein2
left a comment
There was a problem hiding this comment.
This looks great, thanks!
No description provided.