Search in sources :

Example 21 with TopNQueryQueryToolChest

use of org.apache.druid.query.topn.TopNQueryQueryToolChest in project druid by druid-io.

the class CachingClusteredClientTest method testTopNOnPostAggMetricCaching.

@Test
public void testTopNOnPostAggMetricCaching() {
    final TopNQueryBuilder builder = new TopNQueryBuilder().dataSource(DATA_SOURCE).dimension(TOP_DIM).metric("avg_imps_per_row_double").threshold(3).intervals(SEG_SPEC).filters(DIM_FILTER).granularity(GRANULARITY).aggregators(AGGS).postAggregators(POST_AGGS).context(CONTEXT);
    QueryRunner runner = new FinalizeResultsQueryRunner(getDefaultQueryRunner(), new TopNQueryQueryToolChest(new TopNQueryConfig()));
    testQueryCaching(runner, builder.randomQueryId().build(), Intervals.of("2011-01-01/2011-01-02"), makeTopNResultsWithoutRename(), Intervals.of("2011-01-02/2011-01-03"), makeTopNResultsWithoutRename(), Intervals.of("2011-01-05/2011-01-10"), makeTopNResultsWithoutRename(DateTimes.of("2011-01-05"), "a", 50, 4994, "b", 50, 4993, "c", 50, 4992, DateTimes.of("2011-01-06"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-07"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-08"), "a", 50, 4988, "b", 50, 4987, "c", 50, 4986, DateTimes.of("2011-01-09"), "c1", 50, 4985, "b", 50, 4984, "c", 50, 4983), Intervals.of("2011-01-05/2011-01-10"), makeTopNResultsWithoutRename(DateTimes.of("2011-01-05T01"), "a", 50, 4994, "b", 50, 4993, "c", 50, 4992, DateTimes.of("2011-01-06T01"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-07T01"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-08T01"), "a", 50, 4988, "b", 50, 4987, "c", 50, 4986, DateTimes.of("2011-01-09T01"), "c2", 50, 4985, "b", 50, 4984, "c", 50, 4983));
    TopNQuery query = builder.intervals("2011-01-01/2011-01-10").metric("avg_imps_per_row_double").aggregators(AGGS).postAggregators(DIFF_ORDER_POST_AGGS).randomQueryId().build();
    TestHelper.assertExpectedResults(makeTopNResultsWithoutRename(DateTimes.of("2011-01-05"), "a", 50, 4994, "b", 50, 4993, "c", 50, 4992, DateTimes.of("2011-01-05T01"), "a", 50, 4994, "b", 50, 4993, "c", 50, 4992, DateTimes.of("2011-01-06"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-06T01"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-07"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-07T01"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-08"), "a", 50, 4988, "b", 50, 4987, "c", 50, 4986, DateTimes.of("2011-01-08T01"), "a", 50, 4988, "b", 50, 4987, "c", 50, 4986, DateTimes.of("2011-01-09"), "c1", 50, 4985, "b", 50, 4984, "c", 50, 4983, DateTimes.of("2011-01-09T01"), "c2", 50, 4985, "b", 50, 4984, "c", 50, 4983), runner.run(QueryPlus.wrap(query)));
}
Also used : TopNQueryBuilder(org.apache.druid.query.topn.TopNQueryBuilder) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) TopNQueryConfig(org.apache.druid.query.topn.TopNQueryConfig) TopNQuery(org.apache.druid.query.topn.TopNQuery) TopNQueryQueryToolChest(org.apache.druid.query.topn.TopNQueryQueryToolChest) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) QueryRunner(org.apache.druid.query.QueryRunner) Test(org.junit.Test)

Aggregations

TopNQueryConfig (org.apache.druid.query.topn.TopNQueryConfig)21 TopNQueryQueryToolChest (org.apache.druid.query.topn.TopNQueryQueryToolChest)21 TopNQueryBuilder (org.apache.druid.query.topn.TopNQueryBuilder)12 TopNQueryRunnerFactory (org.apache.druid.query.topn.TopNQueryRunnerFactory)12 TopNQuery (org.apache.druid.query.topn.TopNQuery)10 Test (org.junit.Test)9 ByteBuffer (java.nio.ByteBuffer)7 TimeseriesQueryQueryToolChest (org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest)6 CloseableStupidPool (org.apache.druid.collections.CloseableStupidPool)4 FinalizeResultsQueryRunner (org.apache.druid.query.FinalizeResultsQueryRunner)4 QueryRunner (org.apache.druid.query.QueryRunner)4 QueryToolChest (org.apache.druid.query.QueryToolChest)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Map (java.util.Map)3 StupidPool (org.apache.druid.collections.StupidPool)3 Closer (org.apache.druid.java.util.common.io.Closer)3 OffheapBufferGenerator (org.apache.druid.offheap.OffheapBufferGenerator)3 Query (org.apache.druid.query.Query)3 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)3 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)3