Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to retrieve data from Cassandra

I cannot retrieve data from Cassandra after I exit the cli. When I go back to get the data in another session, I get this error:

org.apache.cassandra.db.marshal.MarshalException: cannot parse 'jsmith' as hex bytes

It seems the column family stays and the keyspace too.

I also changed the keys format to ascii (assume Users keys as ascii;)... And that does not stay set either.

Is there a reason why? What is going on?

like image 734
jnbdz Avatar asked Jun 01 '11 21:06

jnbdz


1 Answers

All of the "assume" commands are temporary and limited to a single cli session. For those not sitting in front of the cli right now, we're referring to these:

assume <cf> comparator as <type>;
assume <cf> sub_comparator as <type>;
assume <cf> validator as <type>;
assume <cf> keys as <type>;

Assume one of the attributes (comparator, sub_comparator, validator or keys)
of the given column family match specified type. The specified type will
be used when displaying data returned from the column family.

These are purely client side.

What you want to do instead is to record that metadata permanently in the ColumnFamily definition, e.g. from the readme,

create column family Users with comparator=UTF8Type and default_validation_class=UTF8Type and key_validation_class=UTF8Type;

This is different from "assume" in 3 ways:

  1. It is permanently recorded in Cassandra
  2. Cassandra will enforce the specified type against data inserted
  3. All clients can query and use this metadata to do intelligent things with it, not just the cli

Assume is primarily there as a workaround for old data sets that cannot be updated to use a "real" server-side type.

like image 130
jbellis Avatar answered Sep 30 '22 00:09

jbellis