influxdata / influxdata/influxdb-java

Incorrect long values returned due to json to java conversion

オープン
#276 コメント 23 件 リアクション 1 件 担当者 0 名 GitHub で見る
help wanted kind/bug
主要言語
Java
スター
1.2k
フォーク
469
PR マージ指標
30日以内にマージされた PR はありません

説明

I am having a problem with bad long values being returned due to the conversion to double that happens when all JSON numeric values are stored as Doubles.

This came up first when trying to get back time values as nanoseconds instead of rfc3339 string values. But we need to store very large long values in other fields as well. The application here is scientific instruments, so numerical errors are pretty high priority problems when we are looking at data storage.

From looking around, it does not look like there is a good way to intercept the JSON and convert to Long instead of Double... but maybe I am missing something? I would like to find some way to get these values returned as Long instead of Double. Maybe a different converter? I would appreciate any suggestions or workarounds.

Here is a snippet that recreates the problem:

```
long lval = 1485370052974000001L;

BatchPoints batchPoints = BatchPoints
.database(dbName)
.tag("async", "true")
.retentionPolicy("autogen")
.consistency(ConsistencyLevel.ALL)
.build();
Point point = Point.measurement("testProblems")
.time(innano, TimeUnit.NANOSECONDS)
.addField("double", 3.14)
.addField("long", lval)
.build();

batchPoints.point(point);
influxDB.write(batchPoints);

Series series0 = result.getResults().get(0).getSeries().get(0);
List cols = series0.getColumns();
List val0 = series0.getValues().get(0);

Object outlval_obj = val0.get(cols.indexOf("long"));
if (outlval_obj instanceof Double)
{
long outlval = ((Double)outlval_obj).longValue();
if (outlval != lval)
{
System.err.println("Got bad lval back as double [" + (outlval_obj) + "] -> " + outlval + " != " + lval);
}
}
```

Here is a gist with more code and outputs:
https://gist.github.com/ghmegan/4ed652c8c8dbaf18976c6f5f4c0c6b55

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

提供されている BatchPoints/Point の再現とリンク先の gist から始め、次に long フィールドを Double に変換する JSON 結果変換を追跡します。大きな整数値がどの程度まで損失なくラウンドトリップできるかを確認し、再現された値が壊れた Double ではなく正確に返されることを確認して完了を検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
database
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。