1919 */
2020package com .example .cloud .bigtable .helloworld ;
2121
22- // [START bigtable_hw_imports ]
22+ // [START bigtable_hw_imports_hbase ]
2323import com .google .cloud .bigtable .hbase .BigtableConfiguration ;
2424
2525import org .apache .hadoop .hbase .HColumnDescriptor ;
3636import org .apache .hadoop .hbase .util .Bytes ;
3737
3838import java .io .IOException ;
39- // [END bigtable_hw_imports ]
39+ // [END bigtable_hw_imports_hbase ]
4040
4141/**
4242 * A minimal application that connects to Cloud Bigtable using the native HBase API and performs
@@ -57,25 +57,25 @@ public class HelloWorld {
5757 /** Connects to Cloud Bigtable, runs some basic operations and prints the results. */
5858 private static void doHelloWorld (String projectId , String instanceId ) {
5959
60- // [START bigtable_hw_connect ]
60+ // [START bigtable_hw_connect_hbase ]
6161 // Create the Bigtable connection, use try-with-resources to make sure it gets closed
6262 try (Connection connection = BigtableConfiguration .connect (projectId , instanceId )) {
6363
6464 // The admin API lets us create, manage and delete tables
6565 Admin admin = connection .getAdmin ();
66- // [END bigtable_hw_connect ]
66+ // [END bigtable_hw_connect_hbase ]
6767
6868 try {
69- // [START bigtable_hw_create_table ]
69+ // [START bigtable_hw_create_table_hbase ]
7070 // Create a table with a single column family
7171 HTableDescriptor descriptor = new HTableDescriptor (TableName .valueOf (TABLE_NAME ));
7272 descriptor .addFamily (new HColumnDescriptor (COLUMN_FAMILY_NAME ));
7373
7474 print ("Create table " + descriptor .getNameAsString ());
7575 admin .createTable (descriptor );
76- // [END bigtable_hw_create_table ]
76+ // [END bigtable_hw_create_table_hbase ]
7777
78- // [START bigtable_hw_write_rows ]
78+ // [START bigtable_hw_write_rows_hbase ]
7979 // Retrieve the table we just created so we can do some reads and writes
8080 Table table = connection .getTable (TableName .valueOf (TABLE_NAME ));
8181
@@ -100,18 +100,18 @@ private static void doHelloWorld(String projectId, String instanceId) {
100100 put .addColumn (COLUMN_FAMILY_NAME , COLUMN_NAME , Bytes .toBytes (GREETINGS [i ]));
101101 table .put (put );
102102 }
103- // [END bigtable_hw_write_rows ]
103+ // [END bigtable_hw_write_rows_hbase ]
104104
105- // [START bigtable_hw_get_by_key ]
105+ // [START bigtable_hw_get_by_key_hbase ]
106106 // Get the first greeting by row key
107107 String rowKey = "greeting0" ;
108108 Result getResult = table .get (new Get (Bytes .toBytes (rowKey )));
109109 String greeting = Bytes .toString (getResult .getValue (COLUMN_FAMILY_NAME , COLUMN_NAME ));
110110 System .out .println ("Get a single greeting by row key" );
111111 System .out .printf ("\t %s = %s\n " , rowKey , greeting );
112- // [END bigtable_hw_get_by_key ]
112+ // [END bigtable_hw_get_by_key_hbase ]
113113
114- // [START bigtable_hw_scan_all ]
114+ // [START bigtable_hw_scan_all_hbase ]
115115 // Now scan across all rows.
116116 Scan scan = new Scan ();
117117
@@ -121,14 +121,14 @@ private static void doHelloWorld(String projectId, String instanceId) {
121121 byte [] valueBytes = row .getValue (COLUMN_FAMILY_NAME , COLUMN_NAME );
122122 System .out .println ('\t' + Bytes .toString (valueBytes ));
123123 }
124- // [END bigtable_hw_scan_all ]
124+ // [END bigtable_hw_scan_all_hbase ]
125125
126- // [START bigtable_hw_delete_table ]
126+ // [START bigtable_hw_delete_table_hbase ]
127127 // Clean up by disabling and then deleting the table
128128 print ("Delete the table" );
129129 admin .disableTable (table .getName ());
130130 admin .deleteTable (table .getName ());
131- // [END bigtable_hw_delete_table ]
131+ // [END bigtable_hw_delete_table_hbase ]
132132 } catch (IOException e ) {
133133 if (admin .tableExists (TableName .valueOf (TABLE_NAME ))) {
134134 print ("Cleaning up table" );
0 commit comments