Skip to content

Nanosecond value in Point time field is stored in Long? #267

@gmegan

Description

@gmegan

When creating points to write to influx using Java Instant:

        Instant stamp = Instant.now();
        Point point1 = Point.measurement("cpu")
                .time(stamp.getEpochSecond() * 1000000000 + stamp.getNano(), TimeUnit.NANOSECONDS)
                .addField("idle", 90L)
                .addField("system", 1L)
                .build();

From Java Instant documentation:

The range of an instant requires the storage of a number larger than a long. To achieve this, the class stores a long representing epoch-seconds and an int representing nanosecond-of-second, which will always be between 0 and 999,999,999.

So the previous code may overflow the Long field for time. Maybe time would be better as BigInteger?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions