キーでの読み取り

連続していない行キーのセットを使用して読み取りを行います。

コードサンプル

C++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table, std::vector<std::string> const& row_keys) {
  auto row_set = cbt::RowSet();

  for (auto const& row_key : row_keys) {
    row_set.Append(row_key);
  }

  cbt::Filter filter = cbt::Filter::Latest(1);
  for (StatusOr<cbt::Row>& row : table.ReadRows(std::move(row_set), filter)) {
    if (!row) throw std::move(row).status();
    std::cout << row->row_key() << ":\n";
    for (auto const& cell : row->cells()) {
      std::cout << "\t" << cell.family_name() << ":"
                << cell.column_qualifier() << "    @ "
                << cell.timestamp().count() << "us\n"
                << "\t\"" << cell.value() << '"' << "\n";
    }
  }
}

次のステップ

他の Google Cloud プロダクトに関連するコードサンプルの検索およびフィルタ検索を行うには、Google Cloud のサンプルをご覧ください。