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

The InfluxDBResultMapper is able to handle results with a different time precision #501

Merged
merged 3 commits into from
Sep 6, 2018

Conversation

bednar
Copy link
Contributor

@bednar bednar commented Aug 28, 2018

The InfluxDBResultMapper is not able map QueryResults with different precision than Milliseconds.

@Test
void testToPOJO_Precision() {

	String database = "precision_database";
	influxDB.deleteDatabase(database);
	influxDB.createDatabase(database);

	// write in Nanoseconds
	influxDB.write(database, "autogen", InfluxDB.ConsistencyLevel.ONE,
				"h2o_feet,location=coyote_creek level\\ description=\"below 3 feet\",water_level=2.927 1000000000");

	// query in Seconds
	QueryResult queryResults = influxDB.query(new Query("select * from h2o_feet", database), TimeUnit.SECONDS);

	// Mapper expected time in Milliseconds
	List<H2OFeetMeasurement> measurements = new InfluxDBResultMapper().toPOJO(queryResults, H2OFeetMeasurement.class);

	Assertions.assertEquals(1, measurements.size());
	Assertions.assertEquals("coyote_creek", measurements.get(0).location);
	Assertions.assertEquals(2.927D, (double) measurements.get(0).level);
	Assertions.assertEquals("below 3 feet", measurements.get(0).description);
	Assertions.assertEquals(Instant.ofEpochSecond(1), measurements.get(0).time);
}

@Measurement(name = "h2o_feet", timeUnit = TimeUnit.NANOSECONDS)
public static class H2OFeetMeasurement {

	@Column(name = "location", tag = true)
	private String location;

	@Column(name = "water_level")
	private Double level;

	@Column(name = "level description")
	private String description;

	@Column(name = "time")
	private Instant time;
}

@bednar bednar added this to the 2.13 milestone Aug 28, 2018
@codecov-io
Copy link

codecov-io commented Aug 28, 2018

Codecov Report

Merging #501 into master will decrease coverage by 0.08%.
The diff coverage is 92.3%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #501      +/-   ##
============================================
- Coverage     87.53%   87.45%   -0.09%     
- Complexity      365      369       +4     
============================================
  Files            25       25              
  Lines          1500     1506       +6     
  Branches        167      168       +1     
============================================
+ Hits           1313     1317       +4     
- Misses          120      123       +3     
+ Partials         67       66       -1
Impacted Files Coverage Δ Complexity Δ
...n/java/org/influxdb/impl/InfluxDBResultMapper.java 88.23% <92.3%> (+0.54%) 52 <5> (+5) ⬆️
src/main/java/org/influxdb/InfluxDBException.java 87.27% <0%> (-3.64%) 11% <0%> (-1%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 24c5542...64bd8d7. Read the comment docs.

@majst01 majst01 merged commit f681b8b into influxdata:master Sep 6, 2018
@bednar bednar deleted the precision-pull-request branch October 1, 2018 06:44
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

Successfully merging this pull request may close these issues.

None yet

4 participants