Search in sources :

Example 6 with SearchResultValue

use of io.druid.query.search.SearchResultValue in project druid by druid-io.

the class ServerManagerTest method assertQueryable.

private <T> Future assertQueryable(Granularity granularity, String dataSource, Interval interval, List<Pair<String, Interval>> expected) {
    final Iterator<Pair<String, Interval>> expectedIter = expected.iterator();
    final List<Interval> intervals = Arrays.asList(interval);
    final SearchQuery query = Druids.newSearchQueryBuilder().dataSource(dataSource).intervals(intervals).granularity(granularity).limit(10000).query("wow").build();
    final QueryRunner<Result<SearchResultValue>> runner = serverManager.getQueryRunnerForIntervals(query, intervals);
    return serverManagerExec.submit(new Runnable() {

        @Override
        public void run() {
            Map<String, Object> context = new HashMap<String, Object>();
            Sequence<Result<SearchResultValue>> seq = runner.run(query, context);
            Sequences.toList(seq, Lists.<Result<SearchResultValue>>newArrayList());
            Iterator<SegmentForTesting> adaptersIter = factory.getAdapters().iterator();
            while (expectedIter.hasNext() && adaptersIter.hasNext()) {
                Pair<String, Interval> expectedVals = expectedIter.next();
                SegmentForTesting value = adaptersIter.next();
                Assert.assertEquals(expectedVals.lhs, value.getVersion());
                Assert.assertEquals(expectedVals.rhs, value.getInterval());
            }
            Assert.assertFalse(expectedIter.hasNext());
            Assert.assertFalse(adaptersIter.hasNext());
        }
    });
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) Sequence(io.druid.java.util.common.guava.Sequence) Result(io.druid.query.Result) SearchResultValue(io.druid.query.search.SearchResultValue) Iterator(java.util.Iterator) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Pair(io.druid.java.util.common.Pair) Interval(org.joda.time.Interval)

Example 7 with SearchResultValue

use of io.druid.query.search.SearchResultValue in project druid by druid-io.

the class AppendTest method testSearch.

@Test
public void testSearch() {
    List<Result<SearchResultValue>> expectedResults = Arrays.asList(new Result<SearchResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new SearchResultValue(Arrays.<SearchHit>asList(new SearchHit(placementishDimension, "a"), new SearchHit(qualityDimension, "automotive"), new SearchHit(placementDimension, "mezzanine"), new SearchHit(marketDimension, "total_market")))));
    SearchQuery query = makeSearchQuery();
    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 8 with SearchResultValue

use of io.druid.query.search.SearchResultValue in project druid by druid-io.

the class SchemalessTestFullTest method testFullOnSearch.

private void testFullOnSearch(QueryRunner runner, List<Result<SearchResultValue>> expectedResults, String failMsg) {
    SearchQuery query = Druids.newSearchQueryBuilder().dataSource(dataSource).granularity(allGran).intervals(fullOnInterval).query("a").build();
    failMsg += " search ";
    HashMap<String, Object> context = new HashMap<>();
    Iterable<Result<SearchResultValue>> actualResults = Sequences.toList(runner.run(query, context), Lists.<Result<SearchResultValue>>newArrayList());
    TestHelper.assertExpectedResults(expectedResults, actualResults, failMsg);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) SearchResultValue(io.druid.query.search.SearchResultValue) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Result(io.druid.query.Result)

Example 9 with SearchResultValue

use of io.druid.query.search.SearchResultValue in project druid by druid-io.

the class SchemalessTestSimpleTest method testFullOnSearch.

@Test
public void testFullOnSearch() {
    SearchQuery query = Druids.newSearchQueryBuilder().dataSource(dataSource).granularity(allGran).intervals(fullOnInterval).query("a").build();
    List<Result<SearchResultValue>> expectedResults = Arrays.asList(new Result<SearchResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new SearchResultValue(Arrays.<SearchHit>asList(new SearchHit(placementishDimension, "a"), new SearchHit(qualityDimension, "automotive"), new SearchHit(placementDimension, "mezzanine"), new SearchHit(marketDimension, "total_market")))));
    QueryRunner runner = TestQueryRunners.makeSearchQueryRunner(segment);
    HashMap<String, Object> context = new HashMap<String, Object>();
    TestHelper.assertExpectedResults(expectedResults, runner.run(query, context));
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) SearchResultValue(io.druid.query.search.SearchResultValue) 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 10 with SearchResultValue

use of io.druid.query.search.SearchResultValue in project druid by druid-io.

the class AppendTest method testFilteredSearch2.

@Test
public void testFilteredSearch2() {
    List<Result<SearchResultValue>> expectedResults = Arrays.asList(new Result<SearchResultValue>(new DateTime("2011-01-12T00:00:00.000Z"), new SearchResultValue(Arrays.<SearchHit>asList(new SearchHit(placementishDimension, "a"), new SearchHit(placementDimension, "mezzanine"), new SearchHit(marketDimension, "total_market")))));
    SearchQuery query = makeFilteredSearchQuery();
    QueryRunner runner = TestQueryRunners.makeSearchQueryRunner(segment2);
    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)

Aggregations

Result (io.druid.query.Result)11 SearchResultValue (io.druid.query.search.SearchResultValue)11 SearchQuery (io.druid.query.search.search.SearchQuery)9 HashMap (java.util.HashMap)9 QueryRunner (io.druid.query.QueryRunner)7 SearchHit (io.druid.query.search.search.SearchHit)7 DateTime (org.joda.time.DateTime)6 Test (org.junit.Test)5 ImmutableMap (com.google.common.collect.ImmutableMap)2 FinalizeResultsQueryRunner (io.druid.query.FinalizeResultsQueryRunner)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Interval (org.joda.time.Interval)2 Function (com.google.common.base.Function)1 ImmutableList (com.google.common.collect.ImmutableList)1 HashFunction (com.google.common.hash.HashFunction)1 QueryableDruidServer (io.druid.client.selector.QueryableDruidServer)1 ISE (io.druid.java.util.common.ISE)1 Pair (io.druid.java.util.common.Pair)1 FunctionalIterable (io.druid.java.util.common.guava.FunctionalIterable)1