use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryTest method testSameDoubleSeriesQueryWithAggregation.
@Issue("4714")
@Test(description = "test same double series query")
public void testSameDoubleSeriesQueryWithAggregation() {
SeriesQuery query = new SeriesQuery(TEST_SERIES3.getEntity(), TEST_SERIES3.getMetric());
query.setStartDate("2017-01-01T00:01:00Z");
query.setEndDate("2017-01-01T00:04:00Z");
query.setAggregate(new Aggregate(AggregationType.SUM, new Period(3, TimeUnit.MINUTE, PeriodAlignment.START_TIME)));
List<Series> result = SeriesMethod.querySeriesAsList(query, 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:00Z", new BigDecimal("6.0")));
assertEquals("Incorrect query result with two same series requests", Arrays.asList(expectedSeries, expectedSeries), result);
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate 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, result.get(0));
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryAggregateGroupOrderRateTest method testDefaultOrderGroupAggregate.
@Issue("4729")
@Test(description = "test query result with default Group/Aggregate order")
public void testDefaultOrderGroupAggregate() {
SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(10, TimeUnit.SECOND)));
query.setGroup(new Group(GroupType.MAX, new Period(5, TimeUnit.SECOND)));
List<Series> result = querySeriesAsList(query);
Series expectedSeries = createSeries("*", Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("2.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("2.0")));
assertEquals(result, Collections.singletonList(expectedSeries), "Incorrect query result with default Group/Aggregate order");
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryMultipleYearsGroupTest method testSeriesQueryMultipleYearGroupSingleEntity.
@Issue("4101")
@Issue("4591")
@Test
public void testSeriesQueryMultipleYearGroupSingleEntity() throws Exception {
SeriesQuery query = new SeriesQuery();
query.setEntities(Collections.singletonList(ENTITY_NAME2));
query.setMetric(METRIC_NAME);
query.setStartDate("1900-01-01T00:00:00.000Z");
query.setEndDate("2100-01-01T00:00:00.000Z");
query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(12, TimeUnit.YEAR)));
List<Series> resultSeries = querySeriesAsList(query);
List<Sample> samples = new ArrayList<>();
samples.add(Sample.ofDateInteger("2006-01-01T00:00:00.000Z", 2));
assertSamples(samples, resultSeries.get(0).getData());
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryMultipleYearsGroupTest method testSeriesQueryMultipleYearGroupBothEntities.
@Issue("4101")
@Issue("4591")
@Test
public void testSeriesQueryMultipleYearGroupBothEntities() throws Exception {
SeriesQuery query = new SeriesQuery();
query.setEntities(Arrays.asList(ENTITY_NAME1, ENTITY_NAME2));
query.setMetric(METRIC_NAME);
query.setStartDate("1900-01-01T00:00:00.000Z");
query.setEndDate("2100-01-01T00:00:00.000Z");
query.setAggregate(new Aggregate(AggregationType.COUNT, new Period(12, TimeUnit.YEAR)));
List<Series> resultSeries = querySeriesAsList(query);
List<Sample> samples1 = new ArrayList<>();
/* See #4101#note-18 */
if (zeroTimeOffset <= 0) {
samples1.add(Sample.ofDateInteger("1970-01-01T00:00:00.000Z", 1));
}
samples1.add(Sample.ofDateInteger("2006-01-01T00:00:00.000Z", 2));
samples1.add(Sample.ofDateInteger("2018-01-01T00:00:00.000Z", 1));
List<Sample> samples2 = new ArrayList<>();
samples2.add(Sample.ofDateInteger("2006-01-01T00:00:00.000Z", 2));
assertSamples(samples1, resultSeries.get(0).getData());
assertSamples(samples2, resultSeries.get(1).getData());
}
Aggregations