Search in sources :

Example 1 with AggregationInterpolate

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)));
}
Also used : Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Period(com.axibase.tsd.api.model.Period) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 2 with AggregationInterpolate

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));
}
Also used : Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 3 with AggregationInterpolate

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);
}
Also used : Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) GroupType(com.axibase.tsd.api.model.series.query.transformation.group.GroupType) Period(com.axibase.tsd.api.model.Period) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)

Example 4 with AggregationInterpolate

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);
}
Also used : Period(com.axibase.tsd.api.model.Period) Aggregate(com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate) AggregationType(com.axibase.tsd.api.model.series.query.transformation.aggregate.AggregationType) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)

Example 5 with AggregationInterpolate

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;
}
Also used : Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) GroupType(com.axibase.tsd.api.model.series.query.transformation.group.GroupType) ArrayList(java.util.ArrayList) Period(com.axibase.tsd.api.model.Period) ArrayList(java.util.ArrayList) List(java.util.List) AggregationInterpolate(com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)

Aggregations

AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)12 Period (com.axibase.tsd.api.model.Period)8 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)7 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)7 Issue (io.qameta.allure.Issue)7 Test (org.testng.annotations.Test)7 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)5 AggregationType (com.axibase.tsd.api.model.series.query.transformation.aggregate.AggregationType)3 GroupType (com.axibase.tsd.api.model.series.query.transformation.group.GroupType)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Response (javax.ws.rs.core.Response)2 Series (com.axibase.tsd.api.model.series.Series)1 BigDecimal (java.math.BigDecimal)1