Search in sources :

Example 21 with Aggregate

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");
}
Also used : 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) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 22 with Aggregate

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

Example 23 with Aggregate

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

Example 24 with Aggregate

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

Example 25 with Aggregate

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

Aggregations

Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)30 Issue (io.qameta.allure.Issue)29 Test (org.testng.annotations.Test)29 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)26 Period (com.axibase.tsd.api.model.Period)25 BigDecimal (java.math.BigDecimal)19 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)7 MessageStatsQuery (com.axibase.tsd.api.model.message.MessageStatsQuery)4 Rate (com.axibase.tsd.api.model.series.query.transformation.rate.Rate)4 Response (javax.ws.rs.core.Response)4 Metric (com.axibase.tsd.api.model.metric.Metric)2 Sample (com.axibase.tsd.api.model.series.Sample)2 Series (com.axibase.tsd.api.model.series.Series)2 AggregationInterpolate (com.axibase.tsd.api.model.series.query.transformation.AggregationInterpolate)2 Threshold (com.axibase.tsd.api.model.series.query.transformation.aggregate.Threshold)1 ZonedDateTime (java.time.ZonedDateTime)1