當前位置: 首頁>>代碼示例>>Java>>正文


Java Table類代碼示例

本文整理匯總了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()));
}
 
開發者ID:apache,項目名稱:beam,代碼行數:41,代碼來源:BigtableWriteIT.java

示例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());
}
 
開發者ID:apache,項目名稱:beam,代碼行數:12,代碼來源:BigtableWriteIT.java

示例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());
}
 
開發者ID:apache,項目名稱:beam,代碼行數:7,代碼來源:BigtableWriteIT.java


注:本文中的com.google.bigtable.admin.v2.Table類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。