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
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) {
44
44
// Use try-with-resources to make sure the connection is closed correctly
45
45
try (Connection connection = BigtableConfiguration .connect (projectId , instanceId )) {
46
46
47
+ System .out .println ("--- Connection established with Bigtable Instance ---" );
47
48
// Create a connection to the table that already exists
48
49
// Use try-with-resources to make sure the connection to the table is closed correctly
49
50
try (Table table = connection .getTable (TableName .valueOf (tableId ))) {
50
51
51
52
// Read a row
52
53
String rowKey = "r1" ;
54
+ System .out .printf ("--- Reading for row-key: %s for provided table: %s ---\n " ,
55
+ rowKey , tableId );
53
56
54
57
// Retrieve the result
55
58
Result result = table .get (new Get (Bytes .toBytes (rowKey )));
56
59
57
60
// Convert row data to string
58
61
String rowValue = Bytes .toString (result .value ());
59
62
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 --- " );
61
66
62
67
} catch (IOException e ) {
63
68
// handle exception while connecting to a table
Original file line number Diff line number Diff line change 45
45
@ SuppressWarnings ("checkstyle:abbreviationaswordinname" )
46
46
public class QuickstartIT {
47
47
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
+
49
52
private final String tableId = formatForTest ("my-table" );
50
53
private final String columnFamilyName = "my-column-family" ;
51
54
private final String columnName = "my-column" ;
52
55
private final String data = "my-data" ;
53
56
54
- // provide your project id as an env var
55
- private final String projectId = System .getenv ("GOOGLE_CLOUD_PROJECT" );
56
57
57
58
private String formatForTest (String name ) {
58
59
return name + "-" + UUID .randomUUID ().toString ().substring (0 , 20 );
You can’t perform that action at this time.
0 commit comments