AKIWEB
AKIWEB

Reputation: 19612

RuntimeException: Unknown comparator 'CompositeType'

I need to create CompositeColumns in a Cassandra ColumnFamily.

Each column value will store the something like this-

user-id   column1
123      (Column1-Value  Column1-SchemaName  LastModifiedDate)

same with column2 as well and other columns as well. So I decided to go with something like this-

Below is the description for the columns-

ByteType for Column-Value
UTF8Type for Column-SchemaName
DateType for LastModifiedDate

I created the below columnfamily like this-

create column family USER_DATA
with key_validation_class = 'UTF8Type'
and comparator = 'CompositeType(ByteType,UTF8Type,DateType)'
and default_validation_class = 'UTF8Type'
and gc_grace = 86400
and column_metadata = [ {column_name : 'lmd', validation_class : DateType}];

Let me know if this is the right way to create the above column family?

But as soon as I try to execute the above column, I always get the below error.

[default@userks]     create column family USER_DATA
...         with key_validation_class = 'UTF8Type'
...         and comparator = 'CompositeType(ByteType,UTF8Type,DateType)'
...         and default_validation_class = 'UTF8Type'
...         and gc_grace = 86400
...         and column_metadata = [ {column_name : 'lmd', validation_class : DateType}];

java.lang.RuntimeException: Unknown comparator 'CompositeType(ByteType,UTF8Type,DateType)'. Available functions: bytes, integer, long, int, lexicaluui
d, timeuuid, utf8, ascii, double, countercolumn.

Can anybody help me with this?

Update:-

I just found out about that error, I forgot to add extra s in ByteType.

Below is the ColumnFamily-

create column family USER_DATA
with key_validation_class = 'UTF8Type'
and comparator = 'CompositeType(BytesType,UTF8Type,DateType)'
and default_validation_class = 'UTF8Type'
and gc_grace = 86400
and column_metadata = [ {column_name : 'lmd', validation_class : DateType}];

Below is the error I got..

[default@beprofileks]     create column family USER_DATA
...         with key_validation_class = 'UTF8Type'
...         and comparator = 'CompositeType(BytesType,UTF8Type,DateType)'
...         and default_validation_class = 'UTF8Type'
...         and gc_grace = 86400
...         and column_metadata = [ {column_name : 'lmd', validation_class : DateType}];

java.lang.RuntimeException: org.apache.cassandra.db.marshal.MarshalException: cannot parse 'lmd' as hex bytes

Upvotes: 0

Views: 166

Answers (1)

Richard
Richard

Reputation: 11100

It should be BytesType, not ByteType:

CompositeType(BytesType,UTF8Type,DateType)

The other problem is that lmd is not a valid column name for the comparator CompositeType(BytesType,UTF8Type,DateType). A valid name is, for example, aa00:string:2013-09-19.

Upvotes: 1

Related Questions