You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Float and float are giving unexpected behavior. Float is converting to double, but float is converting to String. Perhaps it would be better to just throw an IllegalFormatConversionException for the primitive, or disqualify both so the API user is aware. I spent a while trying to look for an answer and stumbled upon this:
Not necessarily a bug, but I think if that same exception was thrown, I would have fixed my implementation in less than a minute. Hope this write up helps!
Steps to reproduce:
List the minimal actions needed to reproduce the behavior.
Create a POJO and mark the columns
@Measurement(name = "DHT11")
public class DHT11 implements Sensor {
private final SensorType type = SensorType.DHT11;
@Column(tag = true)
private int deviceId;
@Column
private Float humidity;
@Column
private Float temperature;
@Column(timestamp = true)
private Instant timestamp;
public DHT11(Event event) {
TempEvent e = (TempEvent) event.getEvent();
try {
this.temperature = e.getTemperature();
this.humidity = e.getHumidity();
this.deviceId = e.getDeviceId();
this.timestamp = Instant.now();
} catch (NullPointerException npe) {
npe.printStackTrace();
}
}
public SensorType getType() {
return this.type;
}
}
Write this to influxdb
@Override
public void process(Event event) {
try {
WriteApiBlocking writeApi = client.getWriteApiBlocking();
writeApi.writeMeasurement(WritePrecision.S, factory.getSensorDTO(SensorType.DHT11, event));
} catch (InfluxException ie) {
ie.printStackTrace();
logger.error("It is likely that the database service is not running.");
}
}
View the raw data for _values
Repeat with primitive float
Expected behavior:
Should throw an exception for incompatible types
Actual behavior:
For Float, converts to double.
Whereas, for float converts to a string.
Platform: MacOS Big Sur 11.4 (20F71) M1 chip
Model Name: MacBook Pro
Model Identifier: MacBookPro17,1
Chip: Apple M1
Total Number of Cores: 8 (4 performance and 4 efficiency)
Memory: 16 GB
System Firmware Version: 6723.120.36
OS Loader Version: 6723.120.36
Serial Number (system): C02FT1Q8Q05P
Hardware UUID: E6057655-2B7F-5D28-A7E4-F8CD37B023B7
Provisioning UDID: 00008103-000404920CD9001E
Activation Lock Status: Enabled
The text was updated successfully, but these errors were encountered:
The primitive float should be serialised same way as Float object.
I've prepared a fixed version within #294. Development version of the client will be available after #294 acceptance, stable version in regular release cycle.
Float and float are giving unexpected behavior. Float is converting to double, but float is converting to String. Perhaps it would be better to just throw an IllegalFormatConversionException for the primitive, or disqualify both so the API user is aware. I spent a while trying to look for an answer and stumbled upon this:
https://community.influxdata.com/t/unable-to-use-type-float-solved/7157
Not necessarily a bug, but I think if that same exception was thrown, I would have fixed my implementation in less than a minute. Hope this write up helps!
Steps to reproduce:
List the minimal actions needed to reproduce the behavior.
Expected behavior:
Should throw an exception for incompatible types
Actual behavior:
For
Float
, converts to double.Whereas, for
float
converts to a string.Specifications:
Model Name: MacBook Pro
Model Identifier: MacBookPro17,1
Chip: Apple M1
Total Number of Cores: 8 (4 performance and 4 efficiency)
Memory: 16 GB
System Firmware Version: 6723.120.36
OS Loader Version: 6723.120.36
Serial Number (system): C02FT1Q8Q05P
Hardware UUID: E6057655-2B7F-5D28-A7E4-F8CD37B023B7
Provisioning UDID: 00008103-000404920CD9001E
Activation Lock Status: Enabled
The text was updated successfully, but these errors were encountered: