cassandra cli-get integer column value

rbl8hiat  于 2021-06-15  发布在  Cassandra
关注(0)|答案(1)|浏览(280)

我试图在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).

但是,当我尝试访问age integer列时,出现以下错误:

[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)

有人能解释一下吗?

k4aesqcs

k4aesqcs1#

简而言之:不要尝试使用cli(或通常的thrift api)访问cql表。
长答案:http://www.datastax.com/dev/blog/thrift-to-cql3

相关问题