我正在尝试在 CQLSH 中创建一个表,然后在 CLI 中访问它(只是为了看看如何去做)。尽管这对 varchar 列效果很好,但我在使用 int 列时遇到了问题。
我的列族是在 CSQLSH 中创建的:
创建表用户(userid varchar 主键,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)
请问有人可以对此有所了解吗?