HBase APIs for Java hello world
This example is a "hello world" application, using the Cloud Bigtable HBase client library for Java, that illustrates how to:
- Connect to a Cloud Bigtable instance.
- Create a new table.
- Write data to the table.
- Read the data back.
- Delete the table.
Running the sample
The sample uses the HBase APIs to communicate with
Bigtable. The code for this sample is in the GitHub repository
GoogleCloudPlatform/cloud-bigtable-examples, in the directory
java/hello-world
.
To run this sample program, follow the instructions for the sample on GitHub.
Using the HBase APIs
The sample application connects to Bigtable and demonstrates some simple operations.
Installing and importing the client library
This sample uses the Cloud Bigtable HBase client for Java, as well as Maven. See the instructions for using the client library.
The sample uses the following imports:
Connecting to Bigtable
Connect to Bigtable using the BigtableConfiguration
class.
Creating a table
Use the Admin API to create a table.
Writing rows to a table
Use the Table
class to put rows to the table. For better throughput, consider
using the BigtableBufferedMutator
class.
Reading a row by its key
Get a row directly using its key.
Scanning all table rows
Use the Scan
class to get a range of rows.
Deleting a table
Delete a table using the Admin API.
Putting it all together
Here is the full example without comments.