Read by keys

Read using a noncontiguous set of row keys.

Code sample

C++

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

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::runtime_error(row.status().message());
    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";
    }
  }
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.