From f9aa9c846cf594bad6c4fce0ed6f35094b198488 Mon Sep 17 00:00:00 2001 From: Fernando Machado Date: Wed, 28 Jun 2017 09:53:54 +0200 Subject: [PATCH 1/2] Updated README.md, section QueryResult mapper limitations --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index afe035753..4079714b6 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,7 @@ List cpuList = resultMapper.toPOJO(queryResult, Cpu.class); **QueryResult mapper limitations** - If your InfluxDB query contains multiple SELECT clauses, you will have to call InfluxResultMapper#toPOJO() multiple times to map every measurement returned by QueryResult to the respective POJO; - If your InfluxDB query contains multiple SELECT clauses **for the same measurement**, InfluxResultMapper will process all results because there is no way to distinguish which one should be mapped to your POJO. It may result in an invalid collection being returned; +- A Class field annotated with _@Column(..., tag = true)_ (i.e. a [InfluxDB Tag](https://docs.influxdata.com/influxdb/v1.2/concepts/glossary/#tag-value)) must be declared as _String_. ### Other Usages: From 26e014884a7fa6f41601f0e16b861e1866f66a80 Mon Sep 17 00:00:00 2001 From: Fernando Machado Date: Wed, 28 Jun 2017 09:53:54 +0200 Subject: [PATCH 2/2] Updated README.md and CHANGELOG.md, section QueryResult mapper limitations --- CHANGELOG.md | 4 ++++ README.md | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc1521636..e6676e3b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## 2.8 [unreleased] +#### Fixes + + - InfluxDBResultMapper now is able to process QueryResult created when a GROUP BY clause was used [PR #345](https://github.com/influxdata/influxdb-java/pull/345) + ## v2.7 [2017-06-26] #### Features diff --git a/README.md b/README.md index afe035753..6f0519a9d 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ influxDB.query(query, 20, queryResult -> System.out.println(queryResult)); ``` -#### QueryResult mapper to POJO (version 2.7+ required, unreleased): +#### QueryResult mapper to POJO (version 2.7+ required): An alternative way to handle the QueryResult object is now available. Supposing that you have a measurement _CPU_: @@ -206,13 +206,14 @@ InfluxDB influxDB = InfluxDBFactory.connect("http://localhost:8086", "root", "ro String dbName = "myTimeseries"; QueryResult queryResult = influxDB.query(new Query("SELECT * FROM cpu", dbName)); -InfluxResultMapper resultMapper = new InfluxResultMapper(); // thread-safe - can be reused +InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); // thread-safe - can be reused List cpuList = resultMapper.toPOJO(queryResult, Cpu.class); ``` **QueryResult mapper limitations** - If your InfluxDB query contains multiple SELECT clauses, you will have to call InfluxResultMapper#toPOJO() multiple times to map every measurement returned by QueryResult to the respective POJO; - If your InfluxDB query contains multiple SELECT clauses **for the same measurement**, InfluxResultMapper will process all results because there is no way to distinguish which one should be mapped to your POJO. It may result in an invalid collection being returned; - +- A Class field annotated with _@Column(..., tag = true)_ (i.e. a [InfluxDB Tag](https://docs.influxdata.com/influxdb/v1.2/concepts/glossary/#tag-value)) must be declared as _String_. +-- _Note: With the current released version (2.7), InfluxDBResultMapper does not support QueryResult created by queries using the "GROUP BY" clause. This was fixed by [PR #345](https://github.com/influxdata/influxdb-java/pull/345)._ ### Other Usages: For additional usage examples have a look at [InfluxDBTest.java](https://github.com/influxdb/influxdb-java/blob/master/src/test/java/org/influxdb/InfluxDBTest.java "InfluxDBTest.java")