use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryAggregateGroupOrderRateTest method testAggregateSeriesLimit.
@Issue("4729")
@Test(description = "test query result with aggregate seriesLimit")
public void testAggregateSeriesLimit() {
SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
query.setAggregate(new Aggregate(AggregationType.MIN, new Period(10, TimeUnit.SECOND)));
query.setSeriesLimit(1);
List<Series> result = querySeriesAsList(query);
Series expectedSeries = createSeries(TEST_ENTITY1, Sample.ofDateDecimal("2017-01-01T00:00:00.000Z", new BigDecimal("101.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("111.0")));
assertEquals(result, Collections.singletonList(expectedSeries), "Incorrect query result with aggregate seriesLimit");
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryAggregateGroupOrderRateTest method testExplicitOrderGroupRateAggregate.
@Issue("4729")
@Test(description = "test query result with explicit non-equals Group/Aggregate order")
public void testExplicitOrderGroupRateAggregate() {
SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
query.setAggregate(new Aggregate(AggregationType.SUM, new Period(4, TimeUnit.SECOND), 3));
query.setGroup(new Group(GroupType.MIN, new Period(5, TimeUnit.SECOND), 4));
query.setRate(new Rate(new Period(10, TimeUnit.SECOND), 5));
List<Series> result = querySeriesAsList(query);
Series expectedSeries = createSeries("*", Sample.ofDateDecimal("2017-01-01T00:00:05.000Z", new BigDecimal("32.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("16.0")), Sample.ofDateDecimal("2017-01-01T00:00:15.000Z", new BigDecimal("16.0")));
assertEquals(result, Collections.singletonList(expectedSeries), "Incorrect query result with explicit non-equals Group/Rate/Aggregate order");
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesInsertTest method testBigDecimalAggregatePrecision.
@Issue("2871")
@Test
public void testBigDecimalAggregatePrecision() throws Exception {
String entityName = "e-decimal-2";
String metricName = "m-decimal-2";
BigDecimal number = new BigDecimal("0.6083333332");
ZonedDateTime dateTime = ZonedDateTime.parse(Mocks.ISO_TIME);
Metric metric = new Metric(metricName);
metric.setDataType(DataType.DECIMAL);
MetricMethod.createOrReplaceMetricCheck(metric);
Series series = new Series(entityName, null);
series.setMetric(metricName);
for (int i = 0; i < 12; i++) {
series.addSamples(Sample.ofDateDecimal(dateTime.plusSeconds(5 * i).toString(), number));
}
assertEquals("Failed to insert small decimal series", OK.getStatusCode(), insertSeries(Collections.singletonList(series)).getStatus());
assertSeriesExisting(series);
SeriesQuery seriesQuery = new SeriesQuery(series.getEntity(), series.getMetric(), dateTime.format(DateTimeFormatter.ISO_INSTANT), dateTime.plusMinutes(1).format(DateTimeFormatter.ISO_INSTANT));
seriesQuery.setAggregate(new Aggregate(AggregationType.SUM, new Period(1, TimeUnit.MINUTE)));
List<Series> seriesList = querySeriesAsList(seriesQuery);
assertEquals("Stored small decimal value incorrect", new BigDecimal("7.2999999984"), seriesList.get(0).getData().get(0).getValue());
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesInsertTest method testDoubleAggregatePrecision.
@Issue("2871")
@Test
public void testDoubleAggregatePrecision() throws Exception {
String entityName = "e-double-3";
String metricName = "m-double-3";
BigDecimal number = new BigDecimal("0.6083333332");
final long t = MILLS_TIME;
Metric metric = new Metric(metricName);
metric.setDataType(DataType.DOUBLE);
MetricMethod.createOrReplaceMetricCheck(metric);
Series series = new Series(entityName, null);
series.setMetric(metricName);
for (int i = 0; i < 12; i++) {
String isoDate = Util.ISOFormat(t + i * 5000);
series.addSamples(Sample.ofDateDecimal(isoDate, number));
}
assertEquals("Failed to insert small decimal series", OK.getStatusCode(), insertSeries(Collections.singletonList(series)).getStatus());
assertSeriesExisting(series);
SeriesQuery seriesQuery = new SeriesQuery(series.getEntity(), series.getMetric(), t, t + 1 + 11 * 5000);
seriesQuery.setAggregate(new Aggregate(AggregationType.SUM, new Period(1, TimeUnit.MINUTE)));
List<Series> seriesList = querySeriesAsList(seriesQuery);
assertEquals("Stored small double value incorrect", new BigDecimal("7.299999998400001"), seriesList.get(0).getData().get(0).getValue());
}
use of com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate in project atsd-api-test by axibase.
the class SeriesQueryAggregateGroupOrderRateTest method testExplicitNegativeOrderGroupRateAggregate.
@Issue("4729")
@Test(description = "test query result with explicit negative Group/Aggregate order")
public void testExplicitNegativeOrderGroupRateAggregate() {
SeriesQuery query = new SeriesQuery("*", TEST_METRIC, "2017-01-01T00:00:00Z", "2017-01-01T00:00:20Z");
query.setAggregate(new Aggregate(AggregationType.SUM, new Period(4, TimeUnit.SECOND), -5));
query.setGroup(new Group(GroupType.MIN, new Period(5, TimeUnit.SECOND), -4));
query.setRate(new Rate(new Period(10, TimeUnit.SECOND), -3));
List<Series> result = querySeriesAsList(query);
Series expectedSeries = createSeries("*", Sample.ofDateDecimal("2017-01-01T00:00:05.000Z", new BigDecimal("32.0")), Sample.ofDateDecimal("2017-01-01T00:00:10.000Z", new BigDecimal("16.0")), Sample.ofDateDecimal("2017-01-01T00:00:15.000Z", new BigDecimal("16.0")));
assertEquals(result, Collections.singletonList(expectedSeries), "Incorrect query result with explicit non-equals Group/Rate/Aggregate order");
}
Aggregations