Cassandra 客户端 - 将列检查为字符串
我是 Cassandra 和 Cassandra 的新手。我正在使用 Hector Java 客户端进行写入/读取。
我有以下代码来插入值 -
Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, StringSerializer.get());
mutator.insert("jsmith", stdColumnDefinition, HFactory.createStringColumn("first", "John"));
现在,当我通过 Hector 客户端取回值时 - 它工作正常 -
columnQuery.setColumnFamily(stdColumnDefinition).setKey("jsmith").setName("first");
QueryResult<HColumn<String, String>> result = columnQuery.execute();
但是,当我尝试从命令行 cassandra 客户端获取值时,我得到的数据以字节为单位,而不是人类可读的字符串格式。有没有办法解决这个问题,以便我可以使用 cassandra 客户端吐出字符串 -
这是示例输出 [default@keyspaceUno] 列出 StandardUno ;
使用默认限制 100
RowKey:6a736d697468 => (列=6669727374,值=4a6f686e,时间戳=1317183324576000) => (列 = 6c617374,值 = 536d697468,时间戳 = 1317183324606000)
返回 1 行。
谢谢。
I am new to Cassandra & I am using the Hector Java Client for writing/reading from it.
I've the following code to insert values -
Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, StringSerializer.get());
mutator.insert("jsmith", stdColumnDefinition, HFactory.createStringColumn("first", "John"));
Now, when I get the values back via the Hector client - it works cleanly -
columnQuery.setColumnFamily(stdColumnDefinition).setKey("jsmith").setName("first");
QueryResult<HColumn<String, String>> result = columnQuery.execute();
However, when I try to get the values from the command line cassandra client, I get the data in bytes, rather than human readable String format. Is there a way for me to fix this so that I can use the cassandra client to spit out Strings -
here is the sample output
[default@keyspaceUno] list StandardUno ;
Using default limit of 100
RowKey: 6a736d697468
=> (column=6669727374, value=4a6f686e, timestamp=1317183324576000)
=> (column=6c617374, value=536d697468, timestamp=1317183324606000)
1 Row Returned.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以修改架构,以便 Cassandra 默认将该列解释为字符串,也可以告诉 CLI 如何解释数据,无论是一次性的还是在会话的其余部分,使用“假设“ 命令。
请参阅http://www.datastax.com/docs/ 0.8/dml/using_cli#reading-rows-and-columns 为例。
You can either modify the schema so that Cassandra interprets the column as a string by default, or you can tell the CLI how to interpret the data, either on a one-shot basis, or for the rest of the session, using the "assume" command.
See http://www.datastax.com/docs/0.8/dml/using_cli#reading-rows-and-columns for examples.