Google Cloud Bigtable C++ Client 2.8.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
Google Cloud Platform Bigtable C++ Client Library

Cloud Bigtable is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail.

The Cloud Bigtable C++ Client library offers types and functions to access Cloud Bigtable from C++ applications. It offers access to the Cloud Bigtable API, including admin operations to list, read, write, and delete Instances, Clusters, Tables, and Application Profiles.

Quickstart

The following "Hello World" program should give you a sense of how to use the library.

#include "google/cloud/bigtable/table.h"
int main(int argc, char* argv[]) try {
if (argc != 4) {
std::string const cmd = argv[0];
auto last_slash = std::string(cmd).find_last_of('/');
std::cerr << "Usage: " << cmd.substr(last_slash + 1)
<< " <project_id> <instance_id> <table_id>\n";
return 1;
}
std::string const project_id = argv[1];
std::string const instance_id = argv[2];
std::string const table_id = argv[3];
// Create a namespace alias to make the code easier to read.
namespace cbt = ::google::cloud::bigtable;
cbt::Table table(cbt::MakeDataConnection(),
cbt::TableResource(project_id, instance_id, table_id));
std::string row_key = "r1";
std::string column_family = "cf1";
std::cout << "Getting a single row by row key:" << std::flush;
table.ReadRow(row_key, cbt::Filter::FamilyRegex(column_family));
if (!result) throw std::move(result).status();
if (!result->first) {
std::cout << "Cannot find row " << row_key << " in the table: " << table_id
<< "\n";
return 0;
}
cbt::Cell const& cell = result->second.cells().front();
std::cout << cell.family_name() << ":" << cell.column_qualifier() << " @ "
<< cell.timestamp().count() << "us\n"
<< '"' << cell.value() << '"' << "\n";
return 0;
} catch (google::cloud::Status const& status) {
std::cerr << "google::cloud::Status thrown: " << status << "\n";
return 1;
}
Status const & status() const &

Building and Installing

  • Packaging maintainers or developers who prefer to install the library in a fixed directory (such as /usr/local or /opt) should consult the packaging guide.
  • Developers who prefer using a package manager such as vcpkg, Conda, or Conan should follow the instructions for their package manager.
  • Developers wanting to use the libraries as part of a larger CMake or Bazel project should consult the quickstart guide.
  • Developers wanting to compile the library just to run some examples or tests should read the project's top-level README.
  • Contributors and developers to google-cloud-cpp should consult the guide to set up a development workstation.

Next Steps