我有以下卡桑德拉配置:卡桑德拉和插入浮动列
<ColumnFamily CompareWith="LongType" Name="MiFamily">
但是,当我尝试插入以下值:
public byte[] dateToByte(Date date) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeLong(new Long(1).longValue());
dos.flush();
byte[] data = bos.toByteArray();
return data;
}
我得到以下异常:
Exception in thread "main" me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:A long is exactly 8 bytes)
at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:28)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:103)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:96)
at me.prettyprint.cassandra.service.Operation.executeAndSetResult(FailoverOperator.java:384)
at me.prettyprint.cassandra.service.FailoverOperator.operateSingleIteration(FailoverOperator.java:190)
at me.prettyprint.cassandra.service.FailoverOperator.operate(FailoverOperator.java:99)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.operateWithFailover(KeyspaceServiceImpl.java:151)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.batchInsert(KeyspaceServiceImpl.java:107)
at borrar.PruebasCassandra.insertData(PruebasCassandra.java:77)
at borrar.PruebasCassandra.main(PruebasCassandra.java:96)
Caused by: InvalidRequestException(why:A long is exactly 8 bytes)
at org.apache.cassandra.thrift.Cassandra$batch_insert_result.read(Cassandra.java:13332)
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_insert(Cassandra.java:717)
at org.apache.cassandra.thrift.Cassandra$Client.batch_insert(Cassandra.java:692)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:100)
... 8 more
题外话,但:'dos.writeLong(new Long(1).longValue());'?! ''回合'dos.writeLong(1L);'? – 2010-11-02 14:13:51
你的代码对我来说看起来很好。如预期的那样,字节数组的长度为8。你确定这是导致错误的代码吗? – dogbane 2010-11-02 14:37:19