File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
bigtable/hbase/snippets/src
main/java/com/example/cloud/bigtable/quickstart
test/java/com/example/cloud/bigtable/quickstart/it Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -44,20 +44,25 @@ public static void main(String... args) {
4444 // Use try-with-resources to make sure the connection is closed correctly
4545 try (Connection connection = BigtableConfiguration .connect (projectId , instanceId )) {
4646
47+ System .out .println ("--- Connection established with Bigtable Instance ---" );
4748 // Create a connection to the table that already exists
4849 // Use try-with-resources to make sure the connection to the table is closed correctly
4950 try (Table table = connection .getTable (TableName .valueOf (tableId ))) {
5051
5152 // Read a row
5253 String rowKey = "r1" ;
54+ System .out .printf ("--- Reading for row-key: %s for provided table: %s ---\n " ,
55+ rowKey , tableId );
5356
5457 // Retrieve the result
5558 Result result = table .get (new Get (Bytes .toBytes (rowKey )));
5659
5760 // Convert row data to string
5861 String rowValue = Bytes .toString (result .value ());
5962
60- System .out .printf ("Row r1: %s" , rowValue );
63+ System .out .printf ("Scanned value for Row r1: %s \n " , rowValue );
64+
65+ System .out .println (" --- Finished reading row --- " );
6166
6267 } catch (IOException e ) {
6368 // handle exception while connecting to a table
Original file line number Diff line number Diff line change 4545@ SuppressWarnings ("checkstyle:abbreviationaswordinname" )
4646public class QuickstartIT {
4747
48- private final String instanceId = System .getProperty ("bigtable.test.instance" );
48+ // provide your project id as an env var
49+ private final String projectId = System .getProperty ("bigtable.test.projectID" );
50+ private final String instanceId = System .getProperty ("bigtable.test.instanceID" );
51+
4952 private final String tableId = formatForTest ("my-table" );
5053 private final String columnFamilyName = "my-column-family" ;
5154 private final String columnName = "my-column" ;
5255 private final String data = "my-data" ;
5356
54- // provide your project id as an env var
55- private final String projectId = System .getenv ("GOOGLE_CLOUD_PROJECT" );
5657
5758 private String formatForTest (String name ) {
5859 return name + "-" + UUID .randomUUID ().toString ().substring (0 , 20 );
You can’t perform that action at this time.
0 commit comments