Domanda

I am new to the cassandra world. I created a cassandra table using cqlsh like the following:

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

Now, when I use the cassandra-cli, and do a describe keySpace;, I get

[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

Then, if I did a GET on the column family I get an Exception.

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

What is it that I am doing wrong?

Thanks much in advance!

È stato utile?

Soluzione

What is it that I am doing wrong?

You are creating a column family using CQL and then trying to access it from the CLI. This doesn't work by design and cannot be done, if you however tried accessing the column family from a java driver that supports CQL, you wouldn't have a problem.

If you want support with thrift for a cql created table try adding the WITH COMPACT STORAGE statement to your column family declaration:

CREATE TABLE "userRecommendations" (
  uid text PRIMARY KEY,
  app set<text>
) WITH COMPACT STORAGE;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top