This example is an App Engine application, written in Java, that
writes some "hello world" greetings to a table and reads them back. The
application uses the App Engine runtime and has full access to App Engine
APIs. It runs in the cloud in the App Engine flexible
environment. The code for this application is in the GitHub
repository GoogleCloudPlatform/cloud-bigtable-examples, in the directory
java/gae-flexible-helloworld
.
Overview of the code sample
The code sample includes the following classes:
BigtableHelper
, which provides a connection to Cloud Bigtable.BigtableHelloWorld
, which writes to and reads from Cloud Bigtable.
BigtableHelper
BigtableHelper
provides a method to create a connection to
Cloud Bigtable. It also caches the connection and provides a method that
will retrieve the cached connection if it exists. This is because creating the
connection is a relatively expensive operation.
BigtableHelloWorld
BigtableHelloWorld
is used to write a series of greetings to
Cloud Bigtable, then read them back and display them. The class gets a
Cloud Bigtable connection from BigtableHelper
; uses the connection to
get a Table
object, which enables you to read and write values; and uses the
Table
object to write to and read from the table: