我想将实验数据插入到Cassandra中,其中每个数据的精确度为15位小数。样本数据集如下:
+------------------+-------------------+
| Sampling_Rate | Value1 |
+------------------+-------------------+
| 2.48979187011719 | 0.144110783934593 |
+------------------+-------------------+
我希望将 Sampling_Rate 视为大纪元时间(即 1970-01-01 00:00:02.48979187011719 + 0000 ), Value1 < / strong>存储其全精度值。
为此,我使用describe表插入数据:
CREATE TABLE project_fvag.temp (
sampling_rate timestamp PRIMARY KEY,
value1 double ) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
我还更改了cqlshrc文件,浮点数和双精度都增加了。另外,更改了datetimeformat:
datetimeformat = %Y-%m-%d %H:%M:%S.%.15f%z ;float_precision = 5 ;double_precision = 15
尽管有这些变化,我仍然将结果存储为时间戳和值中的6位小数。什么是更好的策略来存储/看到我的期望?
答案 0 :(得分:0)
对于采样值:因为您将其设置为时间戳,cassandra将以毫秒精度存储它。一种方法是将其存储为十进制。
同样适用于value1。对于value1,使用十进制而不是double重新创建表。