import java.util.List;
import java.util.concurrent.TimeUnit;
import org.influxdb.BatchOptions;
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDBFactory;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.influxdb.dto.QueryResult.Series;
public class Test {
public static void main(String[] args) {
InfluxDB influxDB = null;
try {
String serverURL = "http://127.0.0.1:8086", username = "root", password = "root";
influxDB = InfluxDBFactory.connect(serverURL, username, password);
String databaseName = "mytime";
influxDB.setDatabase(databaseName);
influxDB.enableBatch(BatchOptions.DEFAULTS);
QueryResult queryResult = influxDB
.query(new Query("select * from test"), TimeUnit.NANOSECONDS);
System.out.println(queryResult);
List<Series> seriesList = queryResult.getResults().iterator().next().getSeries();
List<List<Object>> values = seriesList.iterator().next().getValues();
for (List<Object> row : values) {
System.out.println(row);
}
} finally {
if (influxDB != null) {
try {
influxDB.close();
} catch (Exception e) {
System.out.println("Couldn't close the influxDB connection");
}
}
}
}
}
The console is:
QueryResult [results=[Result [series=[Series [name=test, tags=null, columns=[time, field1, tag1], values=[[1.596627109E9, 1.0, 1], [1.434055564E18, 1.0, 1], [1.434055566E18, 1.0, 1], [1.434055568E18, 1.0, 1], [1.434055569E18, 1.0, 1], [1.43405557E18, 1.0, 1], [1.596627109E18, 1.0, 1], [1.596627109E18, 1.0, 1]]]], error=null]], error=null]
[1.596627109E9, 1.0, 1]
[1.434055564E18, 1.0, 1]
[1.434055566E18, 1.0, 1]
[1.434055568E18, 1.0, 1]
[1.434055569E18, 1.0, 1]
[1.43405557E18, 1.0, 1]
[1.596627109E18, 1.0, 1]
[1.596627109E18, 1.0, 1]
Process finished with exit code 0
As you can see, the last two rows have the same timestamp, which is wrong. The real timestamps are 1596627109000000000 and 1596627109000000002 respectively.
Is there a way to get the full precision timestamps?