Question

I'm trying to make simple insert in cassandra with Hector client. I've created simple table:

create table customs (id uuid PRIMARY KEY, char_col_1 varchar);

And try to insert something:

UUID columnId = UUID.randomUUID();

        HColumn<String, String> column =
                HFactory.createColumn(
                        "char_col_1",
                        "test",
                        12345,
                        StringSerializer.get(),
                        StringSerializer.get()
                );


        Mutator<UUID> mutator = HFactory.createMutator(keyspace, UUIDSerializer.get());
        mutator.insert(columnId, "customs", column);

But I always get error:

InvalidRequestException(why:Not enough bytes to read value of component 0)
Was it helpful?

Solution

I think this is because Hector is unable to insert data (through thrift) to a table with non-compact storage. I'm not a hector expert though.

If you create your column family as follows, it might work.

create table customs (id uuid PRIMARY KEY, char_col_1 varchar) with compact storage;

But, why do you need to create a column family in CQL and insert data through hector. That is not a recommended way. You should choose either CQL or thrift.

In your case if you are planning to use hector for all data operations, you can create column family using hector itself or cassandra-cli.

Or if you want CQL only to create column families you can use datastax java driver instead of hector.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top