Skip to content

Commit 200813d

Browse files
committed
Add disclaimer about schema design to Java Hello World.
Using sequential keys should be discouraged, as this really limits Bigtable performance. See: https://cloud.google.com/bigtable/docs/schema-design
1 parent 2f37c82 commit 200813d

File tree

1 file changed

+13
-3
lines changed
  • bigtable/hbase/snippets/src/main/java/com/example/cloud/bigtable/helloworld

1 file changed

+13
-3
lines changed

bigtable/hbase/snippets/src/main/java/com/example/cloud/bigtable/helloworld/HelloWorld.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,17 @@ private static void doHelloWorld(String projectId, String zone, String clusterId
7575
// Write some rows to the table
7676
print("Write some greetings to the table");
7777
for (int i = 0; i < GREETINGS.length; i++) {
78-
// Each row has a unique row key
78+
// Each row has a unique row key.
79+
//
80+
// Note: This example uses sequential numeric IDs for simplicity, but
81+
// this can result in poor performance in a production application.
82+
// Since rows are stored in sorted order by key, sequential keys can
83+
// result in poor distribution of operations across nodes.
84+
//
85+
// For more information about how to design a Bigtable schema for the
86+
// best performance, see the documentation:
87+
//
88+
// https://cloud.google.com/bigtable/docs/schema-design
7989
String rowKey = "greeting" + i;
8090

8191
// Put a single row into the table. We could also pass a list of Puts to write a batch.
@@ -88,8 +98,8 @@ private static void doHelloWorld(String projectId, String zone, String clusterId
8898
String rowKey = "greeting0";
8999
Result getResult = table.get(new Get(Bytes.toBytes(rowKey)));
90100
String greeting = Bytes.toString(getResult.getValue(COLUMN_FAMILY_NAME, COLUMN_NAME));
91-
System.out.println(
92-
String.format("Get a single greeting by row key: %s = %s", rowKey, greeting));
101+
System.out.println("Get a single greeting by row key");
102+
System.out.printf("\t%s = %s\n", rowKey, greeting);
93103

94104
// Now scan across all rows.
95105
Scan scan = new Scan();

0 commit comments

Comments
 (0)