use of com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate in project atsd-api-test by axibase.
the class SeriesQueryTest method testEndTimeAggregationWithInterpolation.
@Issue("4867")
@Test(description = "test END_TIME period align aggregation with interpolation")
public void testEndTimeAggregationWithInterpolation() {
SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query.setStartDate("2017-01-01T00:00:50Z");
query.setEndDate("2017-01-01T00:03:30Z");
Aggregate aggregate = new Aggregate(AggregationType.MAX, new Period(1, TimeUnit.MINUTE, PeriodAlignment.END_TIME));
aggregate.setInterpolate(new AggregationInterpolate(AggregationInterpolateType.PREVIOUS));
query.setAggregate(aggregate);
List<Series> result = SeriesMethod.querySeriesAsList(query);
Series expectedSeries = new Series();
expectedSeries.setEntity(TEST_SERIES3.getEntity());
expectedSeries.setMetric(TEST_SERIES3.getMetric());
expectedSeries.setTags(Mocks.TAGS);
expectedSeries.addSamples(Sample.ofDateDecimal("2017-01-01T00:01:30Z", new BigDecimal("2.0")), Sample.ofDateDecimal("2017-01-01T00:02:30Z", new BigDecimal("3.0")));
assertEquals("Incorrect query result with END_TIME period align aggregation with interpolation", 1, result.size());
assertEquals("Incorrect query result with END_TIME period align aggregation with interpolation", expectedSeries, pullCheckedFields(result.get(0)));
}
use of com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate in project atsd-api-test by axibase.
the class SeriesQueryGroupExampleTest method testExampleSumInterpolation.
@Issue("2995")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#interpolation-1")
public void testExampleSumInterpolation() throws Exception {
SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
Group group = new Group(GroupType.SUM);
group.setInterpolate(new AggregationInterpolate(AggregationInterpolateType.PREVIOUS));
query.setGroup(group);
List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:00.000Z", 12), Sample.ofDateInteger("2016-06-25T08:00:05.000Z", 14), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:15.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:45.000Z", 20), Sample.ofDateInteger("2016-06-25T08:00:59.000Z", 19));
List<Series> groupedSeries = querySeriesAsList(query);
assertEquals("Response should contain only one series", 1, groupedSeries.size());
List<Sample> givenSamples = groupedSeries.get(0).getData();
final String actual = jacksonMapper.writeValueAsString(givenSamples);
final String expected = jacksonMapper.writeValueAsString(expectedSamples);
assertTrue("Grouped series do not match to expected", compareJsonString(expected, actual));
}
use of com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate in project atsd-api-test by axibase.
the class TransformationPermutationsTest method setUpGrouping.
private void setUpGrouping() {
Period period = new Period(5, TimeUnit.MINUTE, PeriodAlignment.START_TIME);
List<GroupType> aggregationFunctions = Arrays.asList(GroupType.FIRST, GroupType.SUM);
AggregationInterpolate interp = new AggregationInterpolate(AggregationInterpolateType.LINEAR, true);
groupSettings = new Group().setPeriod(period).setTypes(aggregationFunctions).setInterpolate(interp);
query.setGroup(groupSettings);
}
use of com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate in project atsd-api-test by axibase.
the class TransformationPermutationsTest method setUpAggregation.
private void setUpAggregation() {
Period period = new Period(3, TimeUnit.MINUTE, PeriodAlignment.START_TIME);
List<AggregationType> aggregationFunctions = Arrays.asList(AggregationType.AVG, AggregationType.SUM, AggregationType.FIRST);
AggregationInterpolate interp = new AggregationInterpolate(AggregationInterpolateType.LINEAR, true);
aggregationSettings = new Aggregate().setPeriod(period).setTypes(aggregationFunctions).setInterpolate(interp);
query.setAggregate(aggregationSettings);
}
use of com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate in project atsd-api-test by axibase.
the class SeriesQueryTransformationWithDifferentForecastTest method generateGroupingSet.
private List<Group> generateGroupingSet() {
List<Group> groups = new ArrayList<>();
List<List<GroupType>> setsGroupType = Arrays.asList(Arrays.asList(GroupType.AVG, GroupType.SUM), Arrays.asList(GroupType.AVG, GroupType.SUM, GroupType.DETAIL));
Period period = new Period(GROUP_PERIOD_COUNT, TimeUnit.MINUTE, PeriodAlignment.START_TIME);
AggregationInterpolate interp = new AggregationInterpolate(AggregationInterpolateType.LINEAR, true);
for (List<GroupType> setGroupType : setsGroupType) {
groups.add(new Group().setPeriod(period).setInterpolate(interp).setTypes(setGroupType));
}
return groups;
}
Aggregations