本文整理汇总了Java中com.google.bigtable.admin.v2.Table类的典型用法代码示例。如果您正苦于以下问题:Java Table类的具体用法?Java Table怎么用?Java Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于com.google.bigtable.admin.v2包,在下文中一共展示了Table类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testE2EBigtableWrite
import com.google.bigtable.admin.v2.Table; //导入依赖的package包/类
@Test
public void testE2EBigtableWrite() throws Exception {
final String tableName = bigtableOptions.getInstanceName().toTableNameStr(tableId);
final String instanceName = bigtableOptions.getInstanceName().toString();
final int numRows = 1000;
final List<KV<ByteString, ByteString>> testData = generateTableData(numRows);
createEmptyTable(instanceName, tableId);
Pipeline p = Pipeline.create(options);
p.apply(GenerateSequence.from(0).to(numRows))
.apply(ParDo.of(new DoFn<Long, KV<ByteString, Iterable<Mutation>>>() {
@ProcessElement
public void processElement(ProcessContext c) {
int index = c.element().intValue();
Iterable<Mutation> mutations =
ImmutableList.of(Mutation.newBuilder()
.setSetCell(
Mutation.SetCell.newBuilder()
.setValue(testData.get(index).getValue())
.setFamilyName(COLUMN_FAMILY_NAME))
.build());
c.output(KV.of(testData.get(index).getKey(), mutations));
}
}))
.apply(BigtableIO.write()
.withBigtableOptions(bigtableOptions)
.withTableId(tableId));
p.run();
// Test number of column families and column family name equality
Table table = getTable(tableName);
assertThat(table.getColumnFamiliesMap().keySet(), Matchers.hasSize(1));
assertThat(table.getColumnFamiliesMap(), Matchers.hasKey(COLUMN_FAMILY_NAME));
// Test table data equality
List<KV<ByteString, ByteString>> tableData = getTableData(tableName);
assertThat(tableData, Matchers.containsInAnyOrder(testData.toArray()));
}
示例2: createEmptyTable
import com.google.bigtable.admin.v2.Table; //导入依赖的package包/类
/** Helper function to create an empty table. */
private void createEmptyTable(String instanceName, String tableId) {
Table.Builder tableBuilder = Table.newBuilder();
tableBuilder.putColumnFamilies(COLUMN_FAMILY_NAME, ColumnFamily.newBuilder().build());
CreateTableRequest.Builder createTableRequestBuilder = CreateTableRequest.newBuilder()
.setParent(instanceName)
.setTableId(tableId)
.setTable(tableBuilder.build());
tableAdminClient.createTable(createTableRequestBuilder.build());
}
示例3: getTable
import com.google.bigtable.admin.v2.Table; //导入依赖的package包/类
/** Helper function to get a table. */
private Table getTable(String tableName) {
GetTableRequest.Builder getTableRequestBuilder = GetTableRequest.newBuilder()
.setName(tableName);
return tableAdminClient.getTable(getTableRequestBuilder.build());
}