将cassandra列设置为set< text>将产生invalidrequestexception

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

我对Cassandra的世界还很陌生。我使用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

然后,如果我在列族上做了一个操作,我会得到一个例外。

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

我做错了什么?
提前多谢!

uyhoqukh

uyhoqukh1#

我做错了什么?
您正在使用cql创建列族,然后尝试从cli访问它。但是,如果您尝试从支持cql的java驱动程序访问列族,那么就不会有问题。
如果您希望对cql创建的表使用thrift支持,请尝试添加 WITH COMPACT STORAGE 您的家庭声明栏声明:

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

相关问题