Skip to content

Commit 252344a

Browse files
committed
Fix errors in BasicTableExample
1 parent 2b5b969 commit 252344a

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

examples/src/main/java/BasicTableExample.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ public static void main(String[] args) {
104104
*/
105105
MapValue value = new MapValue()
106106
.put("cookie_id", 123) // fill in cookie_id field
107-
.put("audience_data", // fill in audience_data field
107+
.putFromJson("audience_data", // fill in audience_data field
108108
"{\"ipaddr\" : \"10.0.00.xxx\"," +
109109
" \"audience_segment\": { " +
110110
" \"sports_lover\" : \"2018-11-30\"," +
111111
" \"book_reader\" : \"2018-12-01\"" +
112112
" }" +
113-
" }");
113+
" }", null);
114114

115115
PutRequest putRequest = new PutRequest()
116116
.setValue(value)
@@ -149,6 +149,18 @@ public static void main(String[] args) {
149149
}
150150
}
151151

152+
/*
153+
* GET the row put via query
154+
*/
155+
key = new MapValue().put("cookie_id", 106);
156+
157+
getRequest = new GetRequest()
158+
.setKey(key)
159+
.setTableName(tableName);
160+
getRes = handle.get(getRequest);
161+
System.out.println("Got row inserted by query: " +
162+
getRes.getValue());
163+
152164
/*
153165
* PUT another row using JSON to enter the entire value
154166
*/
@@ -173,7 +185,8 @@ public static void main(String[] args) {
173185
.setKey(key)
174186
.setTableName(tableName);
175187
getRes = handle.get(getRequest);
176-
System.out.println("Got second row: " + getRes.getValue());
188+
System.out.println("Got row inserted as JSON: " +
189+
getRes.getValue());
177190

178191
/*
179192
* QUERY the table. The table name is inferred from the
@@ -183,7 +196,7 @@ public static void main(String[] args) {
183196
" WHERE cookie_id = 456";
184197

185198
queryRequest = new QueryRequest();
186-
queryRequest.setStatement(insertQuery);
199+
queryRequest.setStatement(query);
187200
try (QueryIterableResult results =
188201
handle.queryIterable(queryRequest)) {
189202
System.out.println("Query results for " + query + ": ");

0 commit comments

Comments
 (0)