GithubHelp home page GithubHelp logo

InfluxDBMapper.toPOJO() bug? about influxdb-java HOT 5 OPEN

trdmm avatar trdmm commented on July 18, 2024
InfluxDBMapper.toPOJO() bug?

from influxdb-java.

Comments (5)

majst01 avatar majst01 commented on July 18, 2024

But this parses to the same timestamp, right

from influxdb-java.

trdmm avatar trdmm commented on July 18, 2024

But this parses to the same timestamp, right

I use TimeUtil.fromInfluxDBTimeFormat(2022-05-24T01:12:23.56Z), the result is 1653354743056 😢

from influxdb-java.

majst01 avatar majst01 commented on July 18, 2024

Can you write a Unit test which demonstrates this BUG please

from influxdb-java.

trdmm avatar trdmm commented on July 18, 2024

Can you write a Unit test which demonstrates this BUG please

OutGzjLocation:

@Data
public class OutGzjLocation {
    @TimeColumn
    @Column(name = "time")
    private String time;
    /** imgID */
    @Column(name = "imgId")
    private int imgId = -1;
}

OutGzjLocationAnother:

    @TimeColumn
    @Column(name = "time")
    private Instant time;
    /** imgID */
    @Column(name = "imgId")
    private int imgId = -1;
SelectQueryImpl query = select().from(ConstantInfluxdb.targetDatabase, "\"10602ef9\"");

QueryResult queryResult = targetInfluxDB.query(query);

// time type is String
List<OutGzjLocation> outGzjLocations = targetInfluxDBMapper.toPOJO(queryResult, OutGzjLocation.class, "10602ef9");
// time type is Instant
List<OutGzjLocationAnother> outGzjLocationAnothers = targetInfluxDBMapper.toPOJO(queryResult, OutGzjLocationAnother.class, "10602ef9");

log.info("======time type is String======");
outGzjLocations.forEach(outGzjLocation -> {
    int imgId = outGzjLocation.getImgId();
    String timeStr = outGzjLocation.getTime();
    if (imgId == 14 || imgId == 15){
        long timestamp = TimeUtil.fromInfluxDBTimeFormat(timeStr);
        log.info("Time str: {}, timestamp: {}, imgId: {}.", timeStr, timestamp,imgId);
    }
});

log.info("======time type is Instant======");
outGzjLocationAnothers.forEach(outGzjLocationAnother -> {
    Instant instant = outGzjLocationAnother.getTime();
    int imgId = outGzjLocationAnother.getImgId();
    if (imgId == 14 || imgId == 15){
        log.info("Time str: {}, timestamp: {}, imgId: {}.", instant.toString(), instant.toEpochMilli(),imgId);
    }
});

The result is:

======time type is String======
Time str: 2022-05-23T12:08:20.56Z, timestamp: 1653307700056, imgId: 14.
Time str: 2022-05-23T12:08:22.56Z, timestamp: 1653307702056, imgId: 15.
======time type is Instant======
Time str: 2022-05-23T12:08:20.560Z, timestamp: 1653307700560, imgId: 14.
Time str: 2022-05-23T12:08:22.560Z, timestamp: 1653307702560, imgId: 15.

from influxdb-java.

majst01 avatar majst01 commented on July 18, 2024

Hi, nice, i mean as a Pull Request referring this Issue

from influxdb-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.