use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method oldStringPrefix.
@Test
public void oldStringPrefix() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
final Aggregator aggr = Aggregators.SUM;
long start_timestamp = 1356998400000L;
storage.addColumn("tsdb-rollup-10m".getBytes(), getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING), "t".getBytes(), new byte[] { 's', 'u', 'm', ':', 0, 0 }, new byte[] { 0x2A });
final int time_interval = interval.getIntervalSeconds();
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 DataPoint dp = dps[0].iterator().next();
assertFalse(dp.isInteger());
assertEquals(42, dp.doubleValue(), 0.001);
assertEquals(start_timestamp, dp.timestamp());
assertEquals(1, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mZimSumLongSingleTS.
// Zimsum == SUM when comparing qualifiers
@Test
public void run10mZimSumLongSingleTS() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
// still have to write as sum
Aggregator aggr = Aggregators.SUM;
long start_timestamp = 1356998400L;
long end_timestamp = 1357041599L;
storeLongRollup(start_timestamp, end_timestamp, false, false, interval, aggr);
aggr = Aggregators.ZIMSUM;
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));
int i = 600;
long ts = start_timestamp * 1000;
for (final DataPoint dp : dps[0]) {
assertFalse(dp.isInteger());
assertEquals(i, dp.doubleValue(), 0.0001);
assertEquals(ts, dp.timestamp());
ts += interval.getIntervalSeconds() * 1000;
i += interval.getIntervalSeconds();
}
assertEquals(72, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mSumFloatSingleTS.
@Test
public void run10mSumFloatSingleTS() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
final Aggregator aggr = Aggregators.SUM;
long start_timestamp = 1356998400L;
final long end_timestamp = 1357041600;
storeFloatRollup(start_timestamp, end_timestamp, true, false, interval, aggr);
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));
double value = 600.5F;
long expected_timestamp = start_timestamp * 1000;
for (DataPoint dp : dps[0]) {
assertEquals(value, dp.doubleValue(), 0.00001);
assertEquals(expected_timestamp, dp.timestamp());
value += interval.getIntervalSeconds();
expected_timestamp += interval.getIntervalSeconds() * 1000;
}
assertEquals(73, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mSumLongDoubleTS.
@Test
public void run10mSumLongDoubleTS() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
final Aggregator aggr = Aggregators.SUM;
long start_timestamp = 1356998400L;
long end_timestamp = 1357041600L;
storeLongRollup(1356998400L, end_timestamp, true, false, interval, aggr);
final int time_interval = interval.getIntervalSeconds();
tags.clear();
setQuery(interval.getInterval(), aggr, tags, aggr);
ts_query.getQueries().get(0).getFilters().clear();
ts_query.validateAndSetQuery();
query.configureFromQuery(ts_query, 0);
final DataPoints[] dps = query.run();
assertEquals(1, dps.length);
assertEquals(METRIC_STRING, dps[0].metricName());
assertEquals(TAGK_STRING, dps[0].getAggregatedTags().get(0));
assertNull(dps[0].getAnnotations());
assertNull(dps[0].getTags().get(TAGK_STRING));
long ts = start_timestamp * 1000;
for (final DataPoint dp : dps[0]) {
assertEquals(43800, dp.doubleValue(), 0.0001);
assertEquals(ts, dp.timestamp());
ts += time_interval * 1000;
}
assertEquals(73, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mSumLongSingleTSInMS.
@Test(expected = IllegalArgumentException.class)
public void run10mSumLongSingleTSInMS() throws Exception {
RollupInterval ten_min_interval = rollup_config.getRollupInterval("10m");
Aggregator aggr = Aggregators.SUM;
long start_timestamp = 1356998400000L;
// rollup doesn't accept timestamps in milliseconds
tsdb.addAggregatePoint(METRIC_STRING, start_timestamp, 0, tags, false, ten_min_interval.getInterval(), aggr.toString(), null).joinUninterruptibly();
}
Aggregations