Search in sources :

Example 26 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 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");
}
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 27 with Aggregate

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

Example 28 with Aggregate

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

Example 29 with Aggregate

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

Example 30 with Aggregate

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;
}
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) Threshold(com.axibase.tsd.api.model.series.query.transformation.aggregate.Threshold)

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