cassandra - 在 cassandra 中何时使用十进制与浮点/ double ?

标签 cassandra datastax

我正在使用 apache cassandra 3.x 版本。我对什么时候应该使用小数和浮点类型感到有些困惑?

Is there any specific use-cases/differences when should go for float or avoid decimal and vice-versa?



我已经完成了一些快速教程,但没有涵盖这种差异。谁能帮我理解这一点?

最佳答案

来自本书学习 Apache Cassandra 马特·布朗:

Cassandra has three types that store non-integer numbers:

  • The float type stores 32-bit IEEE-754 floating point numbers.
  • The double type stores 64-bit IEEE-754 floating point numbers.
  • The decimal type stores variable-precision decimal numbers, with no upper bound on size. Unlike a floating point number, a variable-precision decimal will never suffer from base 10 rounding errors in the fractional part of the number.


但与其他两个相比,十进制可能会占用更多空间。所以,如果是精度问题,你可以去decimal .否则,float/double在大多数情况下都足够好。

关于cassandra - 在 cassandra 中何时使用十进制与浮点/ double ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58450530/

相关文章:

performance - Cassandra vs HDFS 存储分析数据

实时广告平台 MongoDB vs. Cassandra vs. MySQL

scala - saveAsCassandraTable 不是 ....dstream.DStream[(String, Int, String)] 的成员

python - 使用datastax python-driver从cassandra获取正确的时间戳

cassandra - 如果在 Apache Cassandra 中,数据中心和机架不直接与物理机架或数据中心相关,那么如何处理容错?

maven - java.lang.NoClassDefFoundError : Could not initialize class com. datastax.driver.core.Cluster

database - 为什么不像通常使用 MySQL 那样从 "single & small"Cassandra 服务器开始呢?

Cassandra CQL3 条件插入/更新

hadoop - 在一致性 ONE 下读取查询期间 Cassandra 超时(需要 1 个响应,但只有 0 个副本响应)

具有多个空字符的字符缓冲区