盲目跟随http://wiki.apache.org/cassandra/CassandraCli,有人可以解释一下吗?
aaron-mac:apache-cassandra-1.0.0 aaron$ bin/cassandra-cli -host localhost -port 9160
Connected to: "Test Cluster" on localhost/9160
Welcome to the Cassandra CLI.
Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.
[default@unknown] use Keyspace1;
Authenticated to keyspace: Keyspace1
[default@Keyspace1] create column family User with comparator = UTF8Type;
5ef4bad0-fb2a-11e0-0000-242d50cf1ffd
Waiting for schema agreement...
... schemas agree across the cluster
[default@Keyspace1] set User['jsmith']['first'] = 'John';
org.apache.cassandra.db.marshal.MarshalException: cannot parse 'jsmith' as hex bytes
[default@Keyspace1]
答案 0 :(得分:21)
在Cassandra CLI中运行任何set命令之前,建议您执行以下操作:
assume <column_family> keys as utf8;
assume <column_family> comparator as utf8;
assume <column_family> validator as utf8;
这将确保您理解的所有内容和列表都将被理解
P.S:这只适用于Cassandra的新人
答案 1 :(得分:4)
这是旧版Cassandra。现在,默认情况下,键被视为十六进制字节,因此您需要:
set User[utf8('jsmith')]['first'] = 'John';
或做:
assume User keys as utf8;
set User['jsmith']['first'] = 'John';
或者,正如文档中的说明所说:
注意:从Cassandra 0.8开始,我们需要为列族声明key_validation_class:
update column family User with key_validation_class=UTF8Type;
答案 2 :(得分:1)
set User['jsmith'][utf8('first')] = utf8('John');
如果您不确定set
命令,可以键入help set;
,然后显示完整的文档。