influxdata/influxdb-client-java

@Column(name="xxxx")Unable to work

aeasylife opened this issue · 9 comments

Steps to reproduce:
List the minimal actions needed to reproduce the behavior.

  1. I have a demo for querying pojo. However, the 'spendMs' field in the result cannot be obtained. The @ Column (name="spend ms") I used doesn't seem to be effective
    image
    image
    image

  2. This is the information I found through debugging, it seems that my 'name' can only be fixed to configure 'value'.
    image
    image

I want to know if there was a mistake in my approach

Expected behavior:
Describe what you expected to happen.

Actual behavior:
Describe What actually happened.

Specifications:

  • Client Version: v6.8.0
  • InfluxDB Version: v2.7
  • JDK Version: 8

#516
I saw a rejected fix that seemed to be repairable

bednar commented

Hi @aeasylife,

how looks like query output from InfluxDB?

Regards

Hi @aeasylife,

how looks like query output from InfluxDB?

Regards
If I use @ Column (name="spend ms") , the result is null,
if it is @ Column (name="value"), I can get the correct value.
image
image
image
image
image
This is a test that writes 10000 'line protocols' per second, and reads part of the data every 10 seconds for nearly a minute, The duration of each read/write record is recorded
image

bednar commented

@bednar
What does pivot has anything to do with the bug being reported?

@sjoshid the current implementation of the POJO mapper is designed with the expectation that data returned from a query is structured in a uniform tabular format, where each row corresponds to a POJO and each column corresponds to a field within the POJO. This tabular structure is essential for the mapper to correctly associate database fields with the corresponding fields in the POJO.

However, without using the pivot function in your query, each field is returned as a separate table. This results in a fragmented data structure where the mapper cannot correctly associate and deserialize the data into POJOs because it expects all fields for a single object to be in the same table or the same part of the result set.

@sjoshid the mapped Cpu class contains only one field that is mapped to the _value column from the response, which is the primary reason it works correctly.

package example;

import java.time.Instant;

import com.influxdb.annotations.Column;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

public class Cpu {

    @Column(timestamp = true)
    Instant time;

    @Column(name = "_value")
    double usage;

    String host;

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }
}

I still don't know what you are getting at.

But, the more I talk to you more I hate Flux and want to say horrible things about it. So I'll just stop.

Thanks for the explanation.