Skip to content

Cloud Bigtable: tableAdmin sample#4313

Merged
igorbernstein2 merged 6 commits into
googleapis:masterfrom
elisheva-qlogic:tableAdmin
Jan 18, 2019
Merged

Cloud Bigtable: tableAdmin sample#4313
igorbernstein2 merged 6 commits into
googleapis:masterfrom
elisheva-qlogic:tableAdmin

Conversation

@elisheva-qlogic

Copy link
Copy Markdown
Contributor

No description provided.

@elisheva-qlogic elisheva-qlogic requested a review from a team January 9, 2019 14:29
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 9, 2019
// [START bigtable_list_tables]
// Lists tables in the current instance.
try {
List<String> listTables = adminClient.listTables();

This comment was marked as spam.

System.out.println("Table: " + table.getId());
Collection<ColumnFamily> columnFamilies = table.getColumnFamilies();
for (ColumnFamily columnFamily : columnFamilies) {
printColumnFamily(columnFamily);

This comment was marked as spam.

// 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.

}

/** Demonstrates how to create a new instance of the DurationRule. */
public void maxAgeRule() {

This comment was marked as spam.

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.

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.

This comment was marked as spam.

}

/** Demonstrates how to modify a column family's rule. */
public void modifyColumnFamilyRule() {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

if (!matcher.matches()) {
continue;
}
System.out.println("\nGarbage collecting orphaned table: " + tableId);

This comment was marked as spam.

// TODO: add test for tableAdmin.getTableMeta()
// TODO: add test for tableAdmin.listColumnFamilies()

private boolean ruleCheck(Object condition) {

This comment was marked as spam.

continue;
}
String timestampStr = matcher.group(1);
long timestamp = Long.parseLong(timestampStr);

This comment was marked as spam.

@billyjacobson

Copy link
Copy Markdown
Contributor

This is looking pretty good, will just need the TODO tests

@igorbernstein2 igorbernstein2 added the api: bigtable Issues related to the Bigtable API. label Jan 15, 2019
return;
}
instanceName = InstanceName.parse(targetInstance).getInstance();
projectName = InstanceName.parse(targetInstance).getProject();

This comment was marked as spam.

@igorbernstein2 igorbernstein2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks!

@igorbernstein2 igorbernstein2 merged commit 2738502 into googleapis:master Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants