检查列族是否存在

检查列族是否存在。

代码示例

C++

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

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

namespace cbt = ::google::cloud::bigtable;
namespace cbta = ::google::cloud::bigtable_admin;
using ::google::cloud::StatusOr;
[](cbta::BigtableTableAdminClient admin, std::string const& project_id,
   std::string const& instance_id, std::string const& table_id,
   std::string const& family_name) {
  std::string table_name = cbt::TableName(project_id, instance_id, table_id);

  google::bigtable::admin::v2::GetTableRequest r;
  r.set_name(table_name);
  r.set_view(google::bigtable::admin::v2::Table::FULL);

  StatusOr<google::bigtable::admin::v2::Table> schema =
      admin.GetTable(std::move(r));

  if (!schema) throw std::move(schema).status();
  auto pos = schema->column_families().find(family_name);
  if (pos == schema->column_families().end()) {
    std::cout << "The column family <" << family_name << "> does not exist";
    return;
  }
  std::cout << "The column family <" << family_name << "> does exist\n";
}

后续步骤

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