全部读取

执行全表扫描。

包含此代码示例的文档页面

如需查看上下文中使用的代码示例,请参阅以下文档:

代码示例

Go

如需了解如何安装和使用 Bigtable 的客户端库,请参阅 Bigtable 客户端库

log.Printf("Reading all greeting rows:")
err = tbl.ReadRows(ctx, bigtable.PrefixRange(columnName), func(row bigtable.Row) bool {
	item := row[columnFamilyName][0]
	log.Printf("\t%s = %s\n", item.Row, string(item.Value))
	return true
}, bigtable.RowFilter(bigtable.ColumnFilter(columnName)))

if err = client.Close(); err != nil {
	log.Fatalf("Could not close data operations client: %v", err)
}

Java

如需了解如何安装和使用 Bigtable 的客户端库,请参阅 Bigtable 客户端库

try {
  System.out.println("\nReading the entire table");
  Query query = Query.create(tableId);
  ServerStream<Row> rowStream = dataClient.readRows(query);
  List<Row> tableRows = new ArrayList<>();
  for (Row r : rowStream) {
    System.out.println("Row Key: " + r.getKey().toStringUtf8());
    tableRows.add(r);
    for (RowCell cell : r.getCells()) {
      System.out.printf(
          "Family: %s    Qualifier: %s    Value: %s%n",
          cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8());
    }
  }
  return tableRows;
} catch (NotFoundException e) {
  System.err.println("Failed to read a non-existent table: " + e.getMessage());
  return null;
}

PHP

如需了解如何安装和使用 Bigtable 的客户端库,请参阅 Bigtable 客户端库

$columnFamilyId = 'cf1';
$column = 'greeting';
printf('Scanning for all greetings:' . PHP_EOL);
$partialRows = $table->readRows([])->readAll();
foreach ($partialRows as $row) {
    printf('%s' . PHP_EOL, $row[$columnFamilyId][$column][0]['value']);
}

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器