use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestFillingDownsampler method testDownsampler_rollupAvg.
@Test
public void testDownsampler_rollupAvg() {
final RollupInterval interval = RollupInterval.builder().setTable("tsdb-rollup-1h").setPreAggregationTable("tsdb-agg-rollup-1h").setInterval("1h").setRowSpan("1d").build();
final RollupQuery rollup_query = new RollupQuery(interval, Aggregators.AVG, 3600000, Aggregators.SUM);
final long baseTime = 1000L;
final SeekableView source = SeekableViewsForTest.fromArray(new DataPoint[] { MutableDataPoint.ofDoubleValue(baseTime + 25L * 0L, 12.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 1L, 11.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 2L, 10.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 3L, 9.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 4L, 8.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 5L, 7.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 6L, 6.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 7L, 5.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 8L, 4.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 9L, 3.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 10L, 2.), MutableDataPoint.ofDoubleValue(baseTime + 25L * 11L, 1.) });
specification = new DownsamplingSpecification("100ms-avg-nan");
final Downsampler downsampler = new FillingDownsampler(source, baseTime, baseTime + 12L * 25L, specification, 0, 0, rollup_query);
long timestamp = baseTime;
step(downsampler, timestamp, 10.5);
step(downsampler, timestamp += 100, 6.5);
step(downsampler, timestamp += 100, 2.5);
assertFalse(downsampler.hasNext());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mAvgLongSingleTSMissingToZero.
@Test
public void run10mAvgLongSingleTSMissingToZero() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
storePoint(1356998400, 20, Aggregators.SUM, interval);
// storePoint(1356998400, 2, Aggregators.COUNT, interval);
// storePoint(1356999000, 40, Aggregators.SUM, interval);
storePoint(1356999000, 5, Aggregators.COUNT, interval);
storePoint(1356999600, 60, Aggregators.SUM, interval);
// storePoint(1356999600, 3, Aggregators.COUNT, interval);
// storePoint(1357000200, 80, Aggregators.SUM, interval);
storePoint(1357000200, 4, Aggregators.COUNT, interval);
Aggregator aggr = Aggregators.AVG;
setQuery(interval.getInterval(), aggr, tags, aggr);
query.configureFromQuery(ts_query, 0);
final DataPoints[] dps = query.run();
assertEquals(1, dps.length);
assertEquals("", dps[0].metricName());
assertTrue(dps[0].getAggregatedTags().isEmpty());
assertNull(dps[0].getAnnotations());
assertNull(dps[0].getTags().get(TAGK_STRING));
final SeekableView it = dps[0].iterator();
assertFalse(it.hasNext());
assertEquals(0, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method runDupes.
@Test
public void runDupes() throws Exception {
storage.flushStorage();
final RollupInterval interval = rollup_config.getRollupInterval("10m");
final Aggregator aggr = Aggregators.SUM;
tsdb.addAggregatePoint(METRIC_STRING, 1357026600L, Integer.MAX_VALUE, tags, false, interval.getInterval(), aggr.toString(), null).joinUninterruptibly();
tsdb.addAggregatePoint(METRIC_STRING, 1357026600L, 42.5F, tags, false, interval.getInterval(), aggr.toString(), null).joinUninterruptibly();
setQuery(interval.getInterval(), aggr, tags, aggr);
query.configureFromQuery(ts_query, 0);
try {
query.run();
fail("Expected IllegalDataException");
} catch (IllegalDataException e) {
}
config.setFixDuplicates(true);
DataPoints[] dps = query.run();
DataPoint dp = dps[0].iterator().next();
assertEquals(1357026600000L, dp.timestamp());
assertEquals(42.5F, dp.toDouble(), 0.0001);
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mAvgLongSingleTSMissingASum.
@Test
public void run10mAvgLongSingleTSMissingASum() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
storePoint(1356998400, 20, Aggregators.SUM, interval);
storePoint(1356998400, 2, Aggregators.COUNT, interval);
// storePoint(1356999000, 40, Aggregators.SUM, interval);
storePoint(1356999000, 5, Aggregators.COUNT, interval);
storePoint(1356999600, 60, Aggregators.SUM, interval);
storePoint(1356999600, 3, Aggregators.COUNT, interval);
storePoint(1357000200, 80, Aggregators.SUM, interval);
storePoint(1357000200, 4, Aggregators.COUNT, interval);
Aggregator aggr = Aggregators.AVG;
setQuery(interval.getInterval(), aggr, tags, aggr);
query.configureFromQuery(ts_query, 0);
final DataPoints[] dps = query.run();
assertEquals(1, dps.length);
assertEquals(METRIC_STRING, dps[0].metricName());
assertTrue(dps[0].getAggregatedTags().isEmpty());
assertNull(dps[0].getAnnotations());
assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
final SeekableView it = dps[0].iterator();
DataPoint dp = it.next();
assertEquals(1356998400000L, dp.timestamp());
assertEquals(10, dp.doubleValue(), 0.0001);
dp = it.next();
assertEquals(1356999600000L, dp.timestamp());
assertEquals(20, dp.doubleValue(), 0.0001);
dp = it.next();
assertEquals(1357000200000L, dp.timestamp());
assertEquals(20, dp.doubleValue(), 0.0001);
assertFalse(it.hasNext());
assertEquals(3, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mSumLongSingleTSRate.
@Test
public void run10mSumLongSingleTSRate() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
final Aggregator aggr = Aggregators.SUM;
final long start_timestamp = 1356998400;
final long end_timestamp = 1357041600;
storeLongRollup(start_timestamp, end_timestamp, false, false, interval, aggr);
setQuery(interval.getInterval(), aggr, tags, aggr);
ts_query.getQueries().get(0).setRate(true);
query.configureFromQuery(ts_query, 0);
final DataPoints[] dps = query.run();
assertNotNull(dps);
assertEquals(METRIC_STRING, dps[0].metricName());
assertTrue(dps[0].getAggregatedTags().isEmpty());
assertNull(dps[0].getAnnotations());
assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
long expected_timestamp = (start_timestamp + interval.getIntervalSeconds()) * 1000;
for (DataPoint dp : dps[0]) {
assertEquals(1.0F, dp.doubleValue(), 0.00001);
assertEquals(expected_timestamp, dp.timestamp());
expected_timestamp += interval.getIntervalSeconds() * 1000;
}
assertEquals(72, dps[0].size());
}
Aggregations