如何使用 API、QueryBuilder 和批处理将 Json 插入 cassandra
How to insert Json into cassandra using API, QueryBuilder and batch
我看到 JSON 的所有示例都使用查询作为字符串,例如
String cqlStatement = "INSERT INTO users JSON '{\"id\":888 , \"age\":21 ,\"state\":\"TX\"}'";
但我想使用 QueryBuilder,因为我想批量插入。
谢谢
使用Insert.json()方法
Inserts the provided object, using the INSERT INTO ... JSON syntax introduced in Cassandra 2.2.
示例:
QueryBuilder.insertInto("my_data").json("{\"id\": 1, \"value\": \"This is a test\"}");
注意:JSON 字符串中省略的任何列都将默认为 NULL 值(这将导致创建墓碑)。
我看到 JSON 的所有示例都使用查询作为字符串,例如
String cqlStatement = "INSERT INTO users JSON '{\"id\":888 , \"age\":21 ,\"state\":\"TX\"}'";
但我想使用 QueryBuilder,因为我想批量插入。
谢谢
使用Insert.json()方法
Inserts the provided object, using the INSERT INTO ... JSON syntax introduced in Cassandra 2.2.
示例:
QueryBuilder.insertInto("my_data").json("{\"id\": 1, \"value\": \"This is a test\"}");
注意:JSON 字符串中省略的任何列都将默认为 NULL 值(这将导致创建墓碑)。