Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Influx storage type conversion #1005

Open
fishered opened this issue Apr 30, 2024 · 3 comments
Open

About Influx storage type conversion #1005

fishered opened this issue Apr 30, 2024 · 3 comments

Comments

@fishered
Copy link

hello!I'm having a problem
I used influx version 1.X and see write point storage type:

    @SuppressWarnings("checkstyle:finalparameters")
        @Deprecated
        public Builder field(final String field, Object value) {
          if (value instanceof Number) {
            if (value instanceof Byte) {
              value = ((Byte) value).doubleValue();
            } else if (value instanceof Short) {
              value = ((Short) value).doubleValue();
            } else if (value instanceof Integer) {
              value = ((Integer) value).doubleValue();
            } else if (value instanceof Long) {
              value = ((Long) value).doubleValue();
            } else if (value instanceof BigInteger) {
              value = ((BigInteger) value).doubleValue();
            }
          }
          fields.put(field, value);
          return this;
        }

so insert data , All data will be converted to Double, InfluxDBResultMapper entity type must be Double
my dependency:

 <dependency>
            <groupId>org.influxdb</groupId>
            <artifactId>influxdb-java</artifactId>
            <version>2.22</version>
        </dependency>
I want to use Mapper to convert to an entity Is there any other way I can use other types?
@eranl
Copy link
Contributor

eranl commented May 17, 2024

Hi @fishered, I'm not sure I understand the issue. Please see the relevant manual section, and let me know if it answers your question.

@fishered
Copy link
Author

I'm sorry I didn't find what I was looking for, Currently my influx version is 1. X ,In influxdb-java:2.22 I found out: Builder field.
If the type in my POJO is Float or BigDecimal, Converting to double will cause the problem of losing accuracy,
So What should I do?

for Example :
@column(name="voltage")
private Float voltage;

Because the store converts the Float to a Double, Accuracy is lost when fetched @eranl

@eranl
Copy link
Contributor

eranl commented Jun 3, 2024

@fishered, double has higher precision than float.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants