从 erlang 插入 cassandra
我正在尝试从 Erlang R14B02 (通过 thrift 0.6.1)将某些内容插入 cassandra 0.7.6
我正在执行以下操作:
读取记录定义
rr(cassandra_types)。
连接到卡桑德拉
{ok, C}=thrift_client_util:new("localhost", 9160, cassandra_thrift,[{strict_read, false}, {strict_write, false}, {framed, true}])。
尝试插入一个值(时间戳=1, 2=Quorum)
Reply1 = thrift_client:call(C, '插入', ["existing_keyspace", "new_key",#columnPath{column_family = "existing_column_family", column = "existing_column"}, "new_value",1,2])。
但是 nr3 给了我一个 bad_args 错误(1 和 2 工作完美)。正确的论点是什么?
I am trying to insert something into cassandra 0.7.6 from Erlang R14B02 (through thrift 0.6.1)
I am doing the following:
Read record definitions
rr(cassandra_types).
Connect to cassandra
{ok, C}=thrift_client_util:new("localhost", 9160, cassandra_thrift,[{strict_read, false}, {strict_write, false}, {framed, true}]).
Try to insert a value (timestamp=1, 2=Quorum)
Reply1 = thrift_client:call(C, 'insert', ["existing_keyspace", "new_key",#columnPath{column_family = "existing_column_family", column = "existing_column"}, "new_value",1,2]).
But nr3 gives me a bad_args error (1 and 2 work perfectly). What would be the right arguments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不受支持的语言的 API 信息主要位于其 Cassandra Thrift API 文档中。
在 Cassandra 0.7 中,您不需要为大多数操作提供键空间,因此
insert
仅采用[Key, ColumnPath, Column, ConsistencyLevel]
。在尝试插入之前,您需要调用set_keyspace
。 erlang 中的插入将是您的示例缺少插入的行键,我也认为是这样。
顺便说一句,请确保始终更新 C 的值 - 它在每次 thrift_client 调用后都会更改。
?cassandra_ConsistencyLevel_QUORUM 根据内存为 2。
What API information there is for unsupported languages is largely in their Cassandra Thrift API documentation.
In Cassandra 0.7, you don't supply the keyspace for most operations, so
insert
just takes[Key, ColumnPath, Column, ConsistencyLevel]
. You need to callset_keyspace
before attempting the insert. The insert in erlang would beYour example is missing the row key for the insert I think too.
As an aside, make sure you always update the value of C - it changes after every thrift_client call.
?cassandra_ConsistencyLevel_QUORUM is 2 from memory.
这可能会有所帮助,尽管没有特定于 erlang 的代码: http://wiki.apache.org/cassandra/节俭示例
This might help, although there is no erlang-specific code: http://wiki.apache.org/cassandra/ThriftExamples