5

I have a column family AllLog create that

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 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 exception:

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

Please some one help me, where is my mistake in this code?

Nishant
  • 54,584
  • 13
  • 112
  • 127
tnk_peka
  • 1,525
  • 2
  • 15
  • 25

1 Answers1

2

The schema specifies comparator as a Composite type, yet the insertion creates a column with a single string ("name").

libjack
  • 6,403
  • 2
  • 28
  • 36
  • yes i know it but i wonder that: have any solution that i can create a table with a composite key and others column is use UTF8 type ???? i try it in cql3 is okie but in hector , i can't insert data to such table :( :( – tnk_peka Jun 26 '12 at 04:52
  • Not sure what you're asking here... with the specified schema, you should update the code so createColumn uses a Composite name, else revise the schema to make the comparator utf8. – libjack Jun 26 '12 at 13:32