Insert cassandra composite column family with composite key

I have a column family AllLogcreate this

create column family LogData
  with column_type = 'Standard'
  and comparator = 'CompositeType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
  and default_validation_class = 'UTF8Type'
  and key_validation_class = 'CompositeType(UTF8Type,UTF8Type)';

but when I use the mutator to insert:

    String key0 = "key0";
    String key1 = "key1";

    Composite compositeKey = new Composite();
    compositeKey.addComponent(key0, StringSerializer.get());
    compositeKey.addComponent(key1, StringSerializer.get());

    // add
    mutator.addInsertion(compositeKey, columnFamilyName, HFactory.createColumn("name", "value"));
    mutator.execute();

always through an exception:

me.prettyprint.hector.api.exceptions.HInvalidRequestException:
InvalidRequestException(why:Not enough bytes to read value of component 0)

Please help me, where is my error in this code?

+5
source share
1 answer

The schema indicates the comparator as a composite type, but the insert creates a single-row column ("name").

+2
source

All Articles