Example: Simple Command-Line Interface to Cloud Bigtable

This example shows how to create a simple Java application that communicates with Cloud Bigtable through the HBase API. The code for this example is in the GitHub repository GoogleCloudPlatform/cloud-bigtable-examples, in the directory java/simple-cli.

Overview of the code sample

This example includes a single class, HBaseCLI, that communicates with Cloud Bigtable and provides a simple command-line interface (CLI). The HBaseCLI class uses the standard HBase API to communicate with Cloud Bigtable.

For example, the following code, taken from the PutCommand class, writes a value to a column:

// Create a new Put request.
Put put = new Put(Bytes.toBytes(rowId));

// Here we add only one column value to the row but
// multiple column values can be added to the row at
// once by calling this method multiple times.
put.addColumn(Bytes.toBytes(columnFamily), Bytes.toBytes(column), Bytes.toBytes(value));

// Execute the put on the table.
table.put(put);

A Maven POM file is used to build the project. Once the project is built, a shell script, hbasecli.sh, launches the CLI with the correct classpath and boot classpath.

Send feedback about...

Cloud Bigtable Documentation