MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / runPreAggregate

Method runPreAggregate

test/core/TestTsdbQueryQueries.java:1631–1681  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1629 }
1630
1631 @Test
1632 public void runPreAggregate() throws Exception {
1633 storeLongTimeSeriesSeconds(false, false);
1634 final List<byte[]> families = new ArrayList<byte[]>();
1635 families.add("t".getBytes(MockBase.ASCII()));
1636 storage.addTable("tsdb-agg".getBytes(), families);
1637 setupGroupByTagValues();
1638 long start_timestamp = 1356998400L;
1639 Whitebox.setInternalState(tsdb, "agg_tag_key",
1640 config.getString("tsd.rollups.agg_tag_key"));
1641 Whitebox.setInternalState(tsdb, "raw_agg_tag_value",
1642 config.getString("tsd.rollups.raw_agg_tag_value"));
1643 Whitebox.setInternalState(tsdb, "default_interval",
1644 RollupInterval.builder()
1645 .setTable("tsdb")
1646 .setPreAggregationTable("tsdb-agg")
1647 .setInterval("1m")
1648 .setRowSpan("1h")
1649 .build());
1650
1651 tsdb.addAggregatePoint(METRIC_STRING, start_timestamp, 42L, tags, true, null,
1652 null, "SUM");
1653
1654 tags.put(config.getString("tsd.rollups.agg_tag_key"), "SUM");
1655 TSQuery ts_query = new TSQuery();
1656 ts_query.setStart("1356998400");
1657 ts_query.setEnd("1357041600");
1658
1659 final TSSubQuery sub = new TSSubQuery();
1660 sub.setMetric(METRIC_STRING);
1661 sub.setTags(new HashMap<String, String>(tags));
1662 sub.setAggregator("sum");
1663
1664 ts_query.setQueries(Arrays.asList(sub));
1665 ts_query.validateAndSetQuery();
1666 query.configureFromQuery(ts_query, 0);
1667
1668 final DataPoints[] dps = query.run();
1669 assertEquals(1, dps.length);
1670 assertEquals(METRIC_STRING, dps[0].metricName());
1671 assertTrue(dps[0].getAggregatedTags().isEmpty());
1672 assertNull(dps[0].getAnnotations());
1673 assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
1674
1675 long ts = start_timestamp * 1000;
1676 final DataPoint dp = dps[0].iterator().next();
1677 assertTrue(dp.isInteger());
1678 assertEquals(42, dp.longValue());
1679 assertEquals(ts, dp.timestamp());
1680 assertEquals(1, dps[0].size());
1681 }
1682
1683 @Test
1684 public void filterExplicitTagsOK() throws Exception {

Callers

nothing calls this directly

Calls 15

ASCIIMethod · 0.95
builderMethod · 0.95
setStartMethod · 0.95
setEndMethod · 0.95
setMetricMethod · 0.95
setTagsMethod · 0.95
setAggregatorMethod · 0.95
setQueriesMethod · 0.95
validateAndSetQueryMethod · 0.95
isIntegerMethod · 0.95
longValueMethod · 0.95
timestampMethod · 0.95

Tested by

no test coverage detected