Multiple prefixes

Stay organized with collections Save and categorize content based on your preferences.

Read rows with row keys matching any prefix in a list.

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& prefix_list) {
  cbt::Filter filter = cbt::Filter::Latest(1);
  auto row_set = cbt::RowSet();
  for (auto const& prefix : prefix_list) {
    auto row_range_prefix = cbt::RowRange::Prefix(prefix);
    row_set.Append(row_range_prefix);
  }

  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 (cbt::Cell 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.