我是卡桑德拉世界的新手。我使用cqlsh创建了一个cassandra表,如下所示:
CREATE TABLE "userRecommendations" (uid text PRIMARY KEY, app set<text>);
现在,当我使用cassandra-cli并执行describe keySpace;
时,我得到了
[default@keySpace] describe userRecommendations;
ColumnFamily: userRecommendations
Key Validation Class: org.apache.cassandra.db.marshal.UTF8Type
Default column value validator: org.apache.cassandra.db.marshal.BytesType
Columns sorted by: org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.ColumnToCollectionType(617070:org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type)))
GC grace seconds: 0
Compaction min/max thresholds: 0/0
Read repair chance: 0.0
DC Local Read repair chance: 0.0
Populate IO Cache on flush: false
Replicate on write: false
Caching: keys_only
Bloom Filter FP chance: default
Built indexes: []
Compaction Strategy: null
null
然后,如果我对列族进行了GET,我会得到一个异常。
[default@UserInfo] get userRecommendations[utf8('aparna')][utf8('app')];
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:723)
at org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:210)
at org.apache.cassandra.cli.CliMain.processStatementInteractive(CliMain.java:210)
at org.apache.cassandra.cli.CliMain.main(CliMain.java:337)
我做错了什么?
提前多多谢谢!
答案 0 :(得分:1)
我做错了什么?
您正在使用CQL创建列系列,然后尝试从CLI访问它。这不适用于设计并且无法完成,如果您尝试从支持CQL的Java驱动程序访问列系列,则不会有问题。
如果您希望使用thrift支持cql创建的表,请尝试将WITH COMPACT STORAGE
语句添加到列族声明中:
CREATE TABLE "userRecommendations" (
uid text PRIMARY KEY,
app set<text>
) WITH COMPACT STORAGE;