Astyanax Cassandra双精度型 [英] Astyanax Cassandra Double type precision

查看:148
本文介绍了Astyanax Cassandra双精度型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从具有double类型列的Cassandra表中获取Double值.我已经使用CQL3语法创建了该表:

I'm trying to get a Double value from a Cassandra table with a double type column. I've created the table in CQL3 syntax:

CREATE TABLE data_double (
    datetime timestamp,
    value double,
    primary key (datetime)
    );

我插入了一行:

INSERT INTO data_double (datetime,  value) VALUES ('111111111', 123.456);  

当我这样做时:

SELECT * from data_double;

我得到的值为 123.46

为什么将值四舍五入?

谢谢

推荐答案

默认情况下,cqlsh实用工具将仅显示5位精度的浮点数.

The cqlsh utility by default will only display 5 digits of precision for floating point numbers.

您可以通过创建一个cqlshrc文件来增加此内容,该文件的内容如下:

You can increase this by creating a cqlshrc file with contents like the following:

[ui]
float_precision = 10

cqlsh文档页面提供了更多详细信息在可用选项上.

The cqlsh docs page provides more details on the available options.

更新:cqlshrc文件的位置在Cassandra中有所更改.新的默认位置是~/.cassandra/cqlshrc.您还可以通过--cqlshrc命令行选项在其他位置使用文件.

Update: The location of the cqlshrc file changed at some point in Cassandra. The new default location is ~/.cassandra/cqlshrc. You can also use a file in a different location with the --cqlshrc command-line option.

这篇关于Astyanax Cassandra双精度型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆