Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping Cassandra Super Columns

I guess everybody that played with Cassandra already read this article.

I trying to create my schema on CassandraCli, but I am having a lot of problems, can someone guide me to the right way? I am trying to create a similar structure like the Comments column family from the article.

In CassandraCli terminal I type:

create column family posts with column_type = ‘Super’ and comparator = ‘AsciiType’ and subcomparator = TimeUUIDType;

It works fine, there is no doc telling me that if I add a column_metadata attribute those will be for the super columns cause my column family is of type super, i can’t find if it is true so:

create column family posts with column_type = ‘Super’ and comparator = ‘AsciiType’ and subcomparator = ‘TimeUUIDType’ and column_metadata = [{column_name:'body'}];

I am trying to create the same as the comment column family of the article, but when i try to populate

set posts['post1'][timeuuid()][body] = ‘Hello I am Goku!’;

i got:

Invalid UUID string: body

I guess because i chose the subcomparator be of type timeuuid and the body is a string, it should be a timeuuid, so HOW my columns inside the super column which is the type timeuuid could holds columns with string type names as the comments of the article are created?

Thanks

like image 258
Laubstein Avatar asked Jan 13 '11 23:01

Laubstein


1 Answers

I think you switched what comparator_type and subcomparator_type apply to. In super column families, comparator_type applies to the super column names, and subcombparator_type applies to the subcolumn names.

Switch the comparator types and your first example should work.

like image 117
Tyler Hobbs Avatar answered Sep 28 '22 08:09

Tyler Hobbs