Cassandra CLI - 获取整数列值

时间:2013-05-27 14:58:18

标签: cassandra command-line-interface

我正在尝试在CQLSH中创建一个表,然后在CLI中访问它(只是为了看看如何做)。虽然这对varchar列工作得很好,但我在使用int列时遇到了麻烦。

我的列系列是在CSQLSH中创建的:

create table user(userid varchar primary key,age int,isactive int);

然后我插入一行:

insert into user (userid, age, isactive) values('mj',31,1);

现在我切换到CLI,可以在使用list时看到值,或者只是运行“get user ['MJ']”:

[default@test1] get user['mj'];
=> (column=, value=, timestamp=1369665807675000)
=> (column=age, value=31, timestamp=1369665807675000)
=> (columnisactive, value=1, timestamp=1369665807675000)
Returned 3 results.
Elapsed time: 5.7 msec(s).

但是当我尝试访问年龄整数列时,我收到此错误:

[default@test1] get user['mj']['age'] as Int32Type;
Not enough bytes to read value of component 0
InvalidRequestException(why:Not enough bytes to read value of component 0)
    at org.apache.cassandra.thrift.Cassandra$get_result.read(Cassandra.java:6592)
    at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
    at org.apache.cassandra.thrift.Cassandra$Client.recv_get(Cassandra.java:556)
    at org.apache.cassandra.thrift.Cassandra$Client.get(Cassandra.java:541)
    at org.apache.cassandra.cli.CliClient.executeGet(CliClient.java:729)
    at org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:216)
    at org.apache.cassandra.cli.CliMain.processStatementInteractive(CliMain.java:210)
    at org.apache.cassandra.cli.CliMain.main(CliMain.java:337)

有人可以对此有所了解吗?

1 个答案:

答案 0 :(得分:1)

简答:不要尝试使用CLI(或一般的Thrift API)访问CQL表。

更长的回答:http://www.datastax.com/dev/blog/thrift-to-cql3