我有以下列系列:
CREATE COLUMN FAMILY messages with comparator=DateType and key_validation_class=UTF8Type and default_validation_class=UTF8Type;
现在我正在使用Cassandra Thrift存储新数据:
TTransport tr = this.dataSource.getConnection();
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
long timestamp = System.currentTimeMillis();
client.set_keyspace("myTestSPace");
ColumnParent parent = new ColumnParent("messages");
Column messageColumn = new Column();
String time = String.valueOf(timestamp);
messageColumn.setName(time.getBytes());
messageColumn.setValue(toByteBuffer(msg.getText));
messageColumn.setTimestamp(timestamp);
client.insert(toByteBuffer(msg.getAuthor()), parent, messageColumn, ConsistencyLevel.ONE);
但我得到例外:
InvalidRequestException(why:Expected 8 or 0 byte long for date (16))
at org.apache.cassandra.thrift.Cassandra$insert_result.read(Cassandra.java:15198)
at org.apache.cassandra.thrift.Cassandra$Client.recv_insert(Cassandra.java:858)
at org.apache.cassandra.thrift.Cassandra$Client.insert(Cassandra.java:830)
at com.vanilla.cassandra.DaoService.addMessage(DaoService.java:57)
如何做到正确?