开发者

Cassandra Client - examining columns as Strings

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,开发者_JAVA技巧 value=536d697468, timestamp=1317183324606000)

1 Row Returned.

Thanks.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜