Search in sources :

Example 1 with SearchQueryExecutor

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

the class SearchQueryRunner method run.

@Override
public Sequence<Result<SearchResultValue>> run(final Query<Result<SearchResultValue>> input, Map<String, Object> responseContext) {
    if (!(input instanceof SearchQuery)) {
        throw new ISE("Got a [%s] which isn't a %s", input.getClass(), SearchQuery.class);
    }
    final SearchQuery query = (SearchQuery) input;
    final List<SearchQueryExecutor> plan = strategySelector.strategize(query).getExecutionPlan(query, segment);
    final Object2IntRBTreeMap<SearchHit> retVal = new Object2IntRBTreeMap<>(query.getSort().getComparator());
    retVal.defaultReturnValue(0);
    int remain = query.getLimit();
    for (final SearchQueryExecutor executor : plan) {
        retVal.putAll(executor.execute(remain));
        remain -= retVal.size();
    }
    return makeReturnResult(segment, query.getLimit(), retVal);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) SearchHit(io.druid.query.search.search.SearchHit) ISE(io.druid.java.util.common.ISE) SearchQueryExecutor(io.druid.query.search.search.SearchQueryExecutor) Object2IntRBTreeMap(it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap)

Aggregations

ISE (io.druid.java.util.common.ISE)1 SearchHit (io.druid.query.search.search.SearchHit)1 SearchQuery (io.druid.query.search.search.SearchQuery)1 SearchQueryExecutor (io.druid.query.search.search.SearchQueryExecutor)1 Object2IntRBTreeMap (it.unimi.dsi.fastutil.objects.Object2IntRBTreeMap)1