use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryAggregateGroupOrderRateTest method testExplicitEqualsOrderGroupRateAggregate.
@Issue("4729")
@Test(description = "test query result with explicit equals Group/Rate/Aggregate order")
public void testExplicitEqualsOrderGroupRateAggregate() {
SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
query.setGroup(new Group(GroupType.MAX, new Period(5, TimeUnit.SECOND), 0));
query.setRate(new Rate(new Period(2, TimeUnit.SECOND), 0));
query.setAggregate(new Aggregate(AggregationType.SUM, new Period(10, TimeUnit.SECOND), 0));
List<Series> result = querySeriesAsList(query);
Series expectedSeries = createSeries("*", Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("1.6")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("4.0")));
assertEquals(result, Collections.singletonList(expectedSeries), "Incorrect query result with explicit equals Group/Aggregate order");
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryGroupExampleTest method testExampleSumAggregationToGroup.
@Issue("2995")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#group-aggregation")
public void testExampleSumAggregationToGroup() throws Exception {
SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
query.setGroup(new Group(GroupType.SUM, null, 1));
query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(10, TimeUnit.SECOND)));
List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:00.000Z", 3), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 3), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 2), Sample.ofDateInteger("2016-06-25T08:00:40.000Z", 2), Sample.ofDateInteger("2016-06-25T08:00:50.000Z", 1));
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.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryGroupExampleTest method testExampleSumGroupAggregation.
@Issue("2995")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#group-aggregation")
public void testExampleSumGroupAggregation() throws Exception {
final Period period = new Period(10, TimeUnit.SECOND);
SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
query.setGroup(new Group(GroupType.SUM, period));
query.setAggregate(new Aggregate(AggregationType.SUM, period));
List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:00.000Z", 15), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 21), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 16), Sample.ofDateInteger("2016-06-25T08:00:40.000Z", 20), Sample.ofDateInteger("2016-06-25T08:00:50.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.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryGroupExampleTest method testExampleSumGroupToAggregation.
@Issue("2995")
@Test(description = "https://github.com/axibase/atsd-docs/blob/master/api/data/series/group.md#group-aggregation")
public void testExampleSumGroupToAggregation() throws Exception {
SeriesQuery query = prepareDefaultQuery("2016-06-25T08:00:00Z", "2016-06-25T08:01:00Z");
query.setGroup(new Group(GroupType.SUM, new Period(1, TimeUnit.MILLISECOND), 0));
query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(10, TimeUnit.SECOND), 1));
List<Sample> expectedSamples = Arrays.asList(Sample.ofDateInteger("2016-06-25T08:00:00.000Z", 2), Sample.ofDateInteger("2016-06-25T08:00:10.000Z", 2), Sample.ofDateInteger("2016-06-25T08:00:30.000Z", 1), Sample.ofDateInteger("2016-06-25T08:00:40.000Z", 1), Sample.ofDateInteger("2016-06-25T08:00:50.000Z", 1));
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.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryMultipleAggregationTest method createSeriesQuery.
private SeriesQuery createSeriesQuery(AggregationType function) {
SeriesQuery query = new SeriesQuery(TEST_ENTITY, TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:25:00Z");
Aggregate aggregate = new Aggregate(function, new Period(1000, TimeUnit.SECOND, PeriodAlignment.START_TIME));
aggregate.setThreshold(new Threshold(300, 1300));
query.setAggregate(aggregate);
return query;
}
Aggregations