influxdata / influxdata/influxdb-java

Is there any way to use a generic @Measurement annotation when creating classes to use with toPOJO()?

Open
#594 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.2k
Forks
469
PR merge metrics
No merged PRs in 30d

Description

I'm using influx-java and would like to simplify the marshalling of the data returned from influx. I've started working with the toPOJO method from the InfluxDBResultMapper, however it seems that in order for me to get any data into my java objects, I need to have a class defined in advance specific to the measurement I'm querying against (eg, the @Measurement annotation must be specified at compile-time). Given the way our database is designed, this is simply not possible. We maintain a number of distinct measurements per-environment, per-tenant and per-measurement. So, our measurements might look like: productionEnv_tenantId_measurement, where there are a handful of productionEnvs, each with tens of measurements, and n tenantIds (hundreds to thousands).

The POJO I've defined is quite simple - it wants an Instant and a sum for the selected column given a query over time, grouped by time. However, the only way I can get any non-null results into my List is if I specify one (of our possible thousands) of measurements in the class annotation, which is (obviously) not feasible. Is there something I'm missing here? Is there any generic way to re-use my generic POJO to get results from any given measurement? Or do I need to go back to marshalling the data into JSON arrays (which is super not fun)?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with InfluxDBResultMapper.toPOJO() and the @Measurement annotation handling described in the issue. Determine how measurement names are currently selected and whether a generic POJO can be reused for arbitrary measurements. Done means the selected time and sum values map into the POJO without requiring a measurement-specific annotation, or the supported limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.