Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Cassandra和插入浮点列_Java_Cassandra - Fatal编程技术网

Java Cassandra和插入浮点列

Java Cassandra和插入浮点列,java,cassandra,Java,Cassandra,我有以下Cassandra配置: <ColumnFamily CompareWith="LongType" Name="MiFamily"> 我得到以下例外情况: Exception in thread "main" me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:A long is exactly 8 bytes) at me.

我有以下Cassandra配置:


    <ColumnFamily CompareWith="LongType" Name="MiFamily">
我得到以下例外情况:


    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


谢谢你的帮助。我在使用batchInsert时出错。

Cassandra 0.8.1不支持浮点:

  • 添加日期、浮点、双精度和布尔类型(CASSANDRA-2530)
使用Java Hector:

StringSerializer se = new StringSerializer();
FloatSerializer fls = new FloatSerializer();
mutator.insert("mykey", "User", HFactory.createColumn("ftest", 0.12345678f, se, fls));

脱离主题,但是:
dos.writeLong(新的Long(1.longValue())?!如何
dos.writeLong(1L)?我觉得你的代码很好。字节数组的长度如预期的那样为8。你确定这是导致错误的代码吗?你能解释一下你做错了什么以及你是如何修复的吗?其他人可能也有同样的问题。
StringSerializer se = new StringSerializer();
FloatSerializer fls = new FloatSerializer();
mutator.insert("mykey", "User", HFactory.createColumn("ftest", 0.12345678f, se, fls));