I’m able to insert to InfluxDB2 (on-prem) just fine with the influx-client-java, however I’m unsure how to properly “deal with” query results, which I get as a List<FluxTable>. Is there any simple way to get such a result back into POJOs, or use some other query function?
I’m using client.getQueryApi().query("my flux query", "myorganization").
Thanks for your reply. I was able to review it, but as I’m fairly new to Influx apparently I don’t quite get it.
Say I have the following: A object that has two fields, say “val_a” and “val_b”. How am I able to convert a Flux query result back into a POJO while getting the following into variables:
The measurement name
Say I ask for “measurement is X or Y or Z”, then I’d like my POJO to know if it is X or Y or Z.
The value for BOTH “val_a” and “val_b” in a single POJO
Here I seem to get one but not the other. Is this because the POJO converter only concerns itself with a single FluxRecord…? I might be getting something wrong here.
So say that I insert:
my_measurement_1
val_a = 1.23456
val_b = 555
I’d like to query it out asking for for multiple measurements
e.g. a filter for r["_measurement"] == "my_measurement_1" or r["_measurement"] == "my_measurement_2" ... an
And a filter for r["_field"] == "val_a" or r["_field"] == "val_b"
And then be able to bring this back into X separate POJOs which all look (ideally, or as close as possible) like this (pseudocode):
[
Result {
String name = "my_measurement_1";
Double valA = 1.23456;
Integer valB = 555;
},
Result {
String name = "my_measurement_2";
Double valA = 2.46802;
Integer valB = 999;
},
...
]
Feel free to modify if I’m modeling or querying poorly, or if I’m missing something else entirely.
My current, rather unsuccessful attempt is something like:
@Measurement(name = "measurement") // ??? Dynamic? Why specific name?
public class Result {
@Column(name = "val_a")
Double valA;
@Column(name = "val_b")
Integer valB;
@Column(timestamp = true)
Instant time;
}