Search in sources :

Example 1 with CursorBasedExecutor

use of io.druid.query.search.search.CursorOnlyStrategy.CursorBasedExecutor in project druid by druid-io.

the class UseIndexesStrategy method getExecutionPlan.

@Override
public List<SearchQueryExecutor> getExecutionPlan(SearchQuery query, Segment segment) {
    final ImmutableList.Builder<SearchQueryExecutor> builder = ImmutableList.builder();
    final QueryableIndex index = segment.asQueryableIndex();
    final StorageAdapter adapter = segment.asStorageAdapter();
    final List<DimensionSpec> searchDims = getDimsToSearch(adapter.getAvailableDimensions(), query.getDimensions());
    if (index != null) {
        final // pair of bitmap dims and non-bitmap dims
        Pair<List<DimensionSpec>, List<DimensionSpec>> pair = partitionDimensionList(adapter, searchDims);
        final List<DimensionSpec> bitmapSuppDims = pair.lhs;
        final List<DimensionSpec> nonBitmapSuppDims = pair.rhs;
        if (bitmapSuppDims.size() > 0) {
            final BitmapIndexSelector selector = new ColumnSelectorBitmapIndexSelector(index.getBitmapFactoryForDimensions(), VirtualColumns.EMPTY, index);
            // from the non-bitmap-support filter, and then use it to compute the filtered result by intersecting bitmaps.
            if (filter == null || filter.supportsBitmapIndex(selector)) {
                final ImmutableBitmap timeFilteredBitmap = makeTimeFilteredBitmap(index, segment, filter, interval);
                builder.add(new IndexOnlyExecutor(query, segment, timeFilteredBitmap, bitmapSuppDims));
            } else {
                // Fall back to cursor-based execution strategy
                nonBitmapSuppDims.addAll(bitmapSuppDims);
            }
        }
        if (nonBitmapSuppDims.size() > 0) {
            builder.add(new CursorBasedExecutor(query, segment, filter, interval, nonBitmapSuppDims));
        }
    } else {
        builder.add(new CursorBasedExecutor(query, segment, filter, interval, searchDims));
    }
    return builder.build();
}
Also used : DimensionSpec(io.druid.query.dimension.DimensionSpec) ImmutableBitmap(io.druid.collections.bitmap.ImmutableBitmap) ImmutableList(com.google.common.collect.ImmutableList) StorageAdapter(io.druid.segment.StorageAdapter) CursorBasedExecutor(io.druid.query.search.search.CursorOnlyStrategy.CursorBasedExecutor) ColumnSelectorBitmapIndexSelector(io.druid.segment.ColumnSelectorBitmapIndexSelector) QueryableIndex(io.druid.segment.QueryableIndex) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) ColumnSelectorBitmapIndexSelector(io.druid.segment.ColumnSelectorBitmapIndexSelector) BitmapIndexSelector(io.druid.query.filter.BitmapIndexSelector)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableBitmap (io.druid.collections.bitmap.ImmutableBitmap)1 DimensionSpec (io.druid.query.dimension.DimensionSpec)1 BitmapIndexSelector (io.druid.query.filter.BitmapIndexSelector)1 CursorBasedExecutor (io.druid.query.search.search.CursorOnlyStrategy.CursorBasedExecutor)1 ColumnSelectorBitmapIndexSelector (io.druid.segment.ColumnSelectorBitmapIndexSelector)1 QueryableIndex (io.druid.segment.QueryableIndex)1 StorageAdapter (io.druid.segment.StorageAdapter)1 List (java.util.List)1