使用 mutate 删除行

使用 mutate 删除行。

代码示例

C++

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

如需向 Bigtable 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证

namespace cbt = ::google::cloud::bigtable;
[](cbt::Table table, std::vector<std::string> const& keys) {
  cbt::BulkMutation mutation;
  for (auto const& row_key : keys) {
    mutation.emplace_back(
        cbt::SingleRowMutation(row_key, cbt::DeleteFromRow()));
  }
  std::vector<cbt::FailedMutation> failures =
      table.BulkApply(std::move(mutation));
  if (failures.empty()) {
    std::cout << "All rows successfully deleted\n";
    return;
  }
  std::cerr << "The following mutations failed:\n";
  for (auto const& f : failures) {
    std::cerr << "index[" << f.original_index() << "]=" << f.status() << "\n";
  }
}

后续步骤

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