Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove search auto strategy, estimateSelectivity of BitmapColumnIndex #15550

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,5 @@ private Iterable<Integer> intGenerator()
public void doValueSetCheck(Blackhole blackhole, BenchmarkState state)
{
BitmapColumnIndex bitmapIndex = state.stringValueSetIndex.forSortedValuesUtf8(state.values);
bitmapIndex.estimateSelectivity(10_000_000);
}
}
4 changes: 0 additions & 4 deletions docs/querying/searchquery.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ are unique.
queryableIndexSegment, and then evaluates search predicates. If some filters support bitmap indexes, the cursor can read
only the rows which satisfy those filters, thereby saving I/O cost. However, it might be slow with filters of low selectivity.

- "auto" strategy uses a cost-based planner for choosing an optimal search strategy. It estimates the cost of index-only
and cursor-based execution plans, and chooses the optimal one. Currently, it is not enabled by default due to the overhead
of cost estimation.

## Server configuration

The following runtime properties apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.apache.druid.segment.BaseLongColumnValueSelector;
import org.apache.druid.segment.ColumnInspector;
import org.apache.druid.segment.ColumnProcessors;
import org.apache.druid.segment.ColumnSelector;
import org.apache.druid.segment.ColumnSelectorFactory;
import org.apache.druid.segment.DimensionSelector;
import org.apache.druid.segment.column.ColumnCapabilities;
Expand Down Expand Up @@ -271,12 +270,6 @@ public VectorValueMatcher makeVectorMatcher(VectorColumnSelectorFactory factory)
).makeMatcher(predicateFactory);
}

@Override
public boolean supportsSelectivityEstimation(ColumnSelector columnSelector, ColumnIndexSelector indexSelector)
{
return Filters.supportsSelectivityEstimation(this, column, columnSelector, indexSelector);
}

@Override
public boolean canVectorizeMatcher(ColumnInspector inspector)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.apache.druid.query.filter;

import org.apache.druid.segment.ColumnSelector;
import org.apache.druid.segment.ColumnSelectorFactory;

import java.util.HashSet;
Expand Down Expand Up @@ -70,14 +69,4 @@ default Set<String> getRequiredColumns()
return allColumns;
}

@Override
default boolean supportsSelectivityEstimation(ColumnSelector columnSelector, ColumnIndexSelector indexSelector)
{
for (Filter filter : getFilters()) {
if (!filter.supportsSelectivityEstimation(columnSelector, indexSelector)) {
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.apache.druid.segment.ColumnInspector;
import org.apache.druid.segment.ColumnProcessorFactory;
import org.apache.druid.segment.ColumnProcessors;
import org.apache.druid.segment.ColumnSelector;
import org.apache.druid.segment.ColumnSelectorFactory;
import org.apache.druid.segment.DimensionSelector;
import org.apache.druid.segment.column.ColumnCapabilities;
Expand Down Expand Up @@ -267,12 +266,6 @@ public VectorValueMatcher makeVectorMatcher(VectorColumnSelectorFactory factory)
).makeMatcher(new EqualityPredicateFactory(matchValueEval));
}

@Override
public boolean supportsSelectivityEstimation(ColumnSelector columnSelector, ColumnIndexSelector indexSelector)
{
return Filters.supportsSelectivityEstimation(this, column, columnSelector, indexSelector);
}

@Override
public boolean canVectorizeMatcher(ColumnInspector inspector)
{
Expand Down
32 changes: 0 additions & 32 deletions processing/src/main/java/org/apache/druid/query/filter/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.druid.query.BitmapResultFactory;
import org.apache.druid.query.filter.vector.VectorValueMatcher;
import org.apache.druid.segment.ColumnInspector;
import org.apache.druid.segment.ColumnSelector;
import org.apache.druid.segment.ColumnSelectorFactory;
import org.apache.druid.segment.index.BitmapColumnIndex;
import org.apache.druid.segment.vector.VectorColumnSelectorFactory;
Expand Down Expand Up @@ -70,37 +69,6 @@ default VectorValueMatcher makeVectorMatcher(VectorColumnSelectorFactory factory
throw new UOE("Filter[%s] cannot vectorize", getClass().getName());
}

/**
* Estimate selectivity of this filter.
* This method can be used for cost-based query planning like in {@link org.apache.druid.query.search.AutoStrategy}.
* To avoid significant performance degradation for calculating the exact cost,
* implementation of this method targets to achieve rapid selectivity estimation
* with reasonable sacrifice of the accuracy.
* As a result, the estimated selectivity might be different from the exact value.
*
* @param indexSelector Object used to retrieve indexes
*
* @return an estimated selectivity ranging from 0 (filter selects no rows) to 1 (filter selects all rows).
*
* @see Filter#getBitmapColumnIndex(ColumnIndexSelector)
*/
default double estimateSelectivity(ColumnIndexSelector indexSelector)
{
return getBitmapColumnIndex(indexSelector).estimateSelectivity(indexSelector.getNumRows());
}

/**
* Indicates whether this filter supports selectivity estimation.
* A filter supports selectivity estimation if it supports bitmap index and
* the dimension which the filter evaluates does not have multi values.
*
* @param columnSelector Object to check the dimension has multi values.
* @param indexSelector Object used to retrieve bitmap indexes
*
* @return true if this Filter supports selectivity estimation, false otherwise.
*/
boolean supportsSelectivityEstimation(ColumnSelector columnSelector, ColumnIndexSelector indexSelector);

/**
* Returns true if this filter can produce a vectorized matcher from its "makeVectorMatcher" method.
* @param inspector Supplies type information for the selectors this filter will match against
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import org.apache.druid.query.lookup.LookupExtractor;
import org.apache.druid.segment.ColumnInspector;
import org.apache.druid.segment.ColumnProcessors;
import org.apache.druid.segment.ColumnSelector;
import org.apache.druid.segment.ColumnSelectorFactory;
import org.apache.druid.segment.DimensionHandlerUtils;
import org.apache.druid.segment.column.ColumnIndexSupplier;
Expand Down Expand Up @@ -364,12 +363,6 @@ public Filter rewriteRequiredColumns(Map<String, String> columnRewrites)
}
}

@Override
public boolean supportsSelectivityEstimation(ColumnSelector columnSelector, ColumnIndexSelector indexSelector)
{
return Filters.supportsSelectivityEstimation(this, dimension, columnSelector, indexSelector);
}

@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.druid.query.filter.vector.VectorValueMatcherColumnProcessorFactory;
import org.apache.druid.segment.ColumnInspector;
import org.apache.druid.segment.ColumnProcessors;
import org.apache.druid.segment.ColumnSelector;
import org.apache.druid.segment.ColumnSelectorFactory;
import org.apache.druid.segment.column.ColumnIndexSupplier;
import org.apache.druid.segment.column.TypeSignature;
Expand Down Expand Up @@ -158,12 +157,6 @@ public VectorValueMatcher makeVectorMatcher(VectorColumnSelectorFactory factory)
).makeMatcher(NullPredicateFactory.INSTANCE);
}

@Override
public boolean supportsSelectivityEstimation(ColumnSelector columnSelector, ColumnIndexSelector indexSelector)
{
return Filters.supportsSelectivityEstimation(this, column, columnSelector, indexSelector);
}

@Override
public boolean canVectorizeMatcher(ColumnInspector inspector)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.apache.druid.query.ordering.StringComparators;
import org.apache.druid.segment.ColumnInspector;
import org.apache.druid.segment.ColumnProcessors;
import org.apache.druid.segment.ColumnSelector;
import org.apache.druid.segment.ColumnSelectorFactory;
import org.apache.druid.segment.column.ColumnIndexSupplier;
import org.apache.druid.segment.column.ColumnType;
Expand Down Expand Up @@ -358,12 +357,6 @@ public VectorValueMatcher makeVectorMatcher(VectorColumnSelectorFactory factory)
).makeMatcher(getPredicateFactory());
}

@Override
public boolean supportsSelectivityEstimation(ColumnSelector columnSelector, ColumnIndexSelector indexSelector)
{
return Filters.supportsSelectivityEstimation(this, column, columnSelector, indexSelector);
}

@Override
public boolean canVectorizeMatcher(ColumnInspector inspector)
{
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading