2

我是卡桑德拉世界的新手。我使用 cqlsh 创建了一个 cassandra 表,如下所示:

CREATE TABLE "userRecommendations" (uid text PRIMARY KEY, app set<text>);

现在,当我使用 cassandra-cli 并执行 adescribe 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)

我做错了什么?

提前非常感谢!

4

1 回答 1

1

我做错了什么?

您正在使用 CQL 创建列族,然后尝试从 CLI 访问它。这在设计上不起作用并且无法完成,但是如果您尝试从支持 CQL 的 java 驱动程序访问列族,则不会有问题。

如果您想为 cql 创建的表提供 thrift 支持,请尝试将WITH COMPACT STORAGE 语句添加到您的列族声明中:

CREATE TABLE "userRecommendations" (
  uid text PRIMARY KEY,
  app set<text>
) WITH COMPACT STORAGE;
于 2013-06-03T09:16:49.060 回答