Cassandra 客户端 - 将列检查为字符串

发布于 2024-12-06 14:50:19 字数 885 浏览 3 评论 0原文

我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2024-12-13 14:50:19

您可以修改架构,以便 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文