I'm creating dynamic column family and inserting long value by using thrift Api in Cassandra 2.0.7. But its throwing error only for long type. Other types like string , int and byte are working.
InvalidRequestException(why:(String didn't validate.) [Monitor][Groups][since] failed validation)
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result$batch_mutate_resultStandardScheme.read(Cassandra.java:28232)
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result$batch_mutate_resultStandardScheme.read(Cassandra.java:28218)
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:28152)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:1069)
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:1055)
at com.sify.beacon.cf.TestGroups.insertColumns(TestGroups.java:588)
CREATE COLUMN FAMILY Groups
WITH comparator = UTF8Type
AND key_validation_class=UTF8Type
AND default_validation_class = UTF8Type;
Code :
public ColumnOrSuperColumn createColumnOrSuperColumn(String name, long value, long timestamp) throws UnsupportedEncodingException {
ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE);
buffer.putLong(value);
Column column = new Column(ByteBuffer.wrap(name.getBytes("utf-8")));
column.setValue(ByteBuffer.wrap(buffer.array()));
column.setTimestamp(timestamp);
ColumnOrSuperColumn c = new ColumnOrSuperColumn();
c.setColumn(column);
return c;
}
I need to do any other conversion to resolve this issue?
Please advise me if anyone have idea.
I have removed the default_validation_class while creating the keyspace.Then insert is happening including long values.
Thanks for your support
Please change your
default_validation_class = UTF8Type to default_validation_class = LongType
It should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With