Search in sources :

Example 26 with QueryRunner

use of io.druid.query.QueryRunner in project druid by druid-io.

the class AppendTest method testFilteredTopNSeries.

@Test
public void testFilteredTopNSeries() {
    List<Result<TopNResultValue>> expectedResults = Arrays.asList(new Result<TopNResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new TopNResultValue(Arrays.<Map<String, Object>>asList(ImmutableMap.<String, Object>builder().put("market", "spot").put("rows", 1L).put("index", 100.0D).put("addRowsIndexConstant", 102.0D).put("uniques", 0.0D).put("maxIndex", 100.0).put("minIndex", 100.0).build()))));
    TopNQuery query = makeFilteredTopNQuery();
    QueryRunner runner = TestQueryRunners.makeTopNQueryRunner(segment);
    HashMap<String, Object> context = new HashMap<String, Object>();
    TestHelper.assertExpectedResults(expectedResults, runner.run(query, context));
}
Also used : TopNResultValue(io.druid.query.topn.TopNResultValue) HashMap(java.util.HashMap) TopNQuery(io.druid.query.topn.TopNQuery) DateTime(org.joda.time.DateTime) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) Test(org.junit.Test)

Example 27 with QueryRunner

use of io.druid.query.QueryRunner in project druid by druid-io.

the class AppendTest method testFilteredTopNSeries2.

@Test
public void testFilteredTopNSeries2() {
    List<Result<TopNResultValue>> expectedResults = Arrays.asList(new Result<TopNResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new TopNResultValue(Lists.<Map<String, Object>>newArrayList())));
    TopNQuery query = makeFilteredTopNQuery();
    QueryRunner runner = TestQueryRunners.makeTopNQueryRunner(segment2);
    HashMap<String, Object> context = new HashMap<String, Object>();
    TestHelper.assertExpectedResults(expectedResults, runner.run(query, context));
}
Also used : TopNResultValue(io.druid.query.topn.TopNResultValue) HashMap(java.util.HashMap) TopNQuery(io.druid.query.topn.TopNQuery) DateTime(org.joda.time.DateTime) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) Test(org.junit.Test)

Example 28 with QueryRunner

use of io.druid.query.QueryRunner in project druid by druid-io.

the class AppendTest method testFilteredTimeSeries.

@Test
public void testFilteredTimeSeries() {
    List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(new Result<TimeseriesResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new TimeseriesResultValue(ImmutableMap.<String, Object>builder().put("rows", 5L).put("index", 500.0D).put("addRowsIndexConstant", 506.0D).put("uniques", 1.0002442201269182D).put("maxIndex", 100.0D).put("minIndex", 100.0D).build())));
    TimeseriesQuery query = makeFilteredTimeseriesQuery();
    QueryRunner runner = TestQueryRunners.makeTimeSeriesQueryRunner(segment);
    HashMap<String, Object> context = new HashMap<String, Object>();
    TestHelper.assertExpectedResults(expectedResults, runner.run(query, context));
}
Also used : TimeseriesResultValue(io.druid.query.timeseries.TimeseriesResultValue) TimeseriesQuery(io.druid.query.timeseries.TimeseriesQuery) HashMap(java.util.HashMap) DateTime(org.joda.time.DateTime) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) Test(org.junit.Test)

Example 29 with QueryRunner

use of io.druid.query.QueryRunner in project druid by druid-io.

the class AppendTest method testFilteredSearch.

@Test
public void testFilteredSearch() {
    List<Result<SearchResultValue>> expectedResults = Arrays.asList(new Result<SearchResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new SearchResultValue(Arrays.<SearchHit>asList(new SearchHit(placementDimension, "mezzanine"), new SearchHit(marketDimension, "total_market")))));
    SearchQuery query = makeFilteredSearchQuery();
    QueryRunner runner = TestQueryRunners.makeSearchQueryRunner(segment);
    HashMap<String, Object> context = new HashMap<String, Object>();
    TestHelper.assertExpectedResults(expectedResults, runner.run(query, context));
}
Also used : SearchResultValue(io.druid.query.search.SearchResultValue) SearchQuery(io.druid.query.search.search.SearchQuery) SearchHit(io.druid.query.search.search.SearchHit) HashMap(java.util.HashMap) DateTime(org.joda.time.DateTime) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) Test(org.junit.Test)

Example 30 with QueryRunner

use of io.druid.query.QueryRunner in project druid by druid-io.

the class AppendTest method testTimeSeries.

@Test
public void testTimeSeries() {
    List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(new Result<TimeseriesResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new TimeseriesResultValue(ImmutableMap.<String, Object>builder().put("rows", 8L).put("index", 700.0D).put("addRowsIndexConstant", 709.0D).put("uniques", 1.0002442201269182D).put("maxIndex", 100.0D).put("minIndex", 0.0D).build())));
    TimeseriesQuery query = makeTimeseriesQuery();
    QueryRunner runner = TestQueryRunners.makeTimeSeriesQueryRunner(segment);
    HashMap<String, Object> context = new HashMap<String, Object>();
    TestHelper.assertExpectedResults(expectedResults, runner.run(query, context));
}
Also used : TimeseriesResultValue(io.druid.query.timeseries.TimeseriesResultValue) TimeseriesQuery(io.druid.query.timeseries.TimeseriesQuery) HashMap(java.util.HashMap) DateTime(org.joda.time.DateTime) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) Test(org.junit.Test)

Aggregations

QueryRunner (io.druid.query.QueryRunner)96 Test (org.junit.Test)72 FinalizeResultsQueryRunner (io.druid.query.FinalizeResultsQueryRunner)55 DateTime (org.joda.time.DateTime)53 Result (io.druid.query.Result)49 Interval (org.joda.time.Interval)47 HashMap (java.util.HashMap)43 TimeseriesQuery (io.druid.query.timeseries.TimeseriesQuery)24 Query (io.druid.query.Query)23 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)23 TimeseriesResultValue (io.druid.query.timeseries.TimeseriesResultValue)21 QueryToolChest (io.druid.query.QueryToolChest)20 GroupByQueryRunnerTest (io.druid.query.groupby.GroupByQueryRunnerTest)20 TimeseriesQueryQueryToolChest (io.druid.query.timeseries.TimeseriesQueryQueryToolChest)18 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)16 ArrayList (java.util.ArrayList)16 AggregatorFactory (io.druid.query.aggregation.AggregatorFactory)14 CountAggregatorFactory (io.druid.query.aggregation.CountAggregatorFactory)14 IOException (java.io.IOException)14 List (java.util.List)14