Skip to content

allow Expr to provide optimized BitmapColumnIndex implementations to optimize ExpressionFilter #18094

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

clintropolis
Copy link
Member

Description

changes:

  • added asBitmapColumnIndex method to Expr, pushing down the default implementation of ExpressionFilter.getBitmapColumnIndex into this new method
  • added asColumnIndexSupplier and asBitmapColumnIndex to Function interface, to allow Expr that use Function to further specialize participation in filtering
  • ExpressionFilter now completely delegates to Expr for its getBitmapColumnIndex method
  • Moved predicate factory out of ExpressionFilter to standalone ExpressionDruidPredicateFactory since it is now used by the default implementation of Expr.asBitmapColumnIndex
  • added implementation of asBitmapColumnIndex to BinEqExpression so that the equals expression can use ValueIndex (except for string columns matching numeric values since that requires predicate indexes)
  • added implementation of asBitmapColumnIndex to MvOverlapConstantArray function to allow it use to ValueSetIndex with a string match value type

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

…optimize ExpressionFilter

changes:
* added `asBitmapColumnIndex` method to `Expr`, pushing down the default implementation of `ExpressionFilter.getBitmapColumnIndex` into this new method
* added `asColumnIndexSupplier` and `asBitmapColumnIndex` to `Function` interface, to allow `Expr` that use `Function` to further specialize participation in filtering
* `ExpressionFilter` now completely delegates to `Expr` for its `getBitmapColumnIndex` method
* Moved predicate factory out of `ExpressionFilter` to standalone `ExpressionDruidPredicateFactory` since it is now used by the default implementation of `Expr.asBitmapColumnIndex`
* added implementation of `asBitmapColumnIndex` to `BinEqExpression` so that the equals expression can use `ValueIndex` (except for string columns matching numeric values since that requires predicate indexes)
* added implementation of `asBitmapColumnIndex` to `MvOverlapConstantArray` function to allow it use to `ValueSetIndex` with a string match value type
*/
@Nullable
default ColumnIndexSupplier asColumnIndexSupplier(
ColumnIndexSelector selector,

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'selector' is never used.
@Nullable
default ColumnIndexSupplier asColumnIndexSupplier(
ColumnIndexSelector selector,
@Nullable ColumnType outputType,

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'outputType' is never used.
default ColumnIndexSupplier asColumnIndexSupplier(
ColumnIndexSelector selector,
@Nullable ColumnType outputType,
List<Expr> args

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'args' is never used.
}
}
return null;
return expr.get().asBitmapColumnIndex(selector);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉


@Nullable
@Override
public BitmapColumnIndex asBitmapColumnIndex(ColumnIndexSelector selector, List<Expr> args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What testing strategy do you have in mind for stuff like this? I suppose we could add items to ExpressionFilterTest. But ideally it would be possible to test them in FunctionTest. What do you think about extending that to have an assertBooleanExpr that calls asBitmapColumnIndex with an index selector that has indexes for the bindings?

With that, I'd also suggest updating assertExpr to check if the expr has a boolean return type, and throw if it does (so they all get moved to assertBooleanExpr).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants