-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Create a FilterBundle.Builder class and use it to construct FilterBundle. #17055
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 🤘
Could you please re-run some of the benchmarks of #15838 just to make sure everything is still working as expected?
processing/src/main/java/org/apache/druid/query/filter/Filter.java
Outdated
Show resolved
Hide resolved
@@ -732,8 +731,7 @@ private static FilterBundle makeFilterBundle( | |||
return null; | |||
} | |||
final long bitmapConstructionStartNs = System.nanoTime(); | |||
final FilterBundle filterBundle = filter.makeFilterBundle( | |||
bitmapIndexSelector, | |||
final FilterBundle filterBundle = new FilterBundle.Builder(filter, bitmapIndexSelector).build( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just in case we should add a new boolean query context flag, https://github.com/apache/druid/blob/master/processing/src/main/java/org/apache/druid/query/QueryContexts.java, something like "cursorAutoArrangeFilters"
and pass it into the builder so that we can disable the sort per query if we need to for any reason.
You can get access to the QueryContext
itself from the CursorBuildSpec
passed into the constructor of QueryableIndexCursorHolder
, pass it into the CursorResources
to feed to this method, and retrieve the value with something like queryContext.getBoolean(QueryContexts.CURSOR_AUTO_ARRANGE_FILTERS)
(or whatever you name the static variable).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would make the change to add the flag - thanks for the suggestion!
processing/src/main/java/org/apache/druid/query/filter/FilterBundle.java
Outdated
Show resolved
Hide resolved
processing/src/main/java/org/apache/druid/query/filter/FilterBundle.java
Outdated
Show resolved
Hide resolved
Will do! out of curiosity, are benchmark tests being ran regularly, or integrated with any workflows?
|
b2cf54f
to
a874b5a
Compare
…r/OrFilter to use it when making FilterBundle.
765b2b9
to
028cf80
Compare
028cf80
to
60a32f5
Compare
processing/src/main/java/org/apache/druid/query/filter/Filter.java
Outdated
Show resolved
Hide resolved
@@ -112,6 +113,7 @@ public QueryableIndexCursorHolder( | |||
Cursors.getTimeOrdering(ordering), | |||
interval, | |||
filter, | |||
cursorBuildSpec.getQueryContext().getBoolean(QueryContexts.CURSOR_AUTO_ARRANGE_FILTERS, false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably default this to true, or are you planning to wait until we have added the cost computations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤘
…ilter. Also removed the getFilter method and updated AndFilter/OrFilter to use the build method instead.
Refactors how FilterBundle is constructed in Filter and QueryableIndexCursorHolder.
Description
Before this PR,
QueryableIndexCursorHolder
callsFilter.makeFilterBundle
to build FilterBundle. TheBitmapColumnIndex.computeBitmapResult
is called at the same time. In the logical AndFilter and OrFilter, the ordering of child filters would affect what indices are chosen. Since filters could have different compute cost (a.k.a union multiple bitmaps is more expensive than single bitmap), we'd like less expensive filters to be computed first.After this PR,
QueryableIndexCursorHolder
builds aFilterBundle.Builder
instance, which contains useful information such asColumnIndexSelector
andBitmapColumnIndex
, then callsbuilds
to build FilterBundle. The actual build logic still exists inFilter.makeFilterBundle
, sinceAndFilter/OrFilter
could have separate logic from otherFilter
. This enablesAndFilter/OrFilter
to sort its child filters by the computing cost in ascending order, before making theBitmapColumnIndex.computeBitmapResult
calls.For now, all indices would have a cost of
Integer.MAX_VALUE
, I intend to make a future PR to update cost for all inheritedBitmapColumnIndex
classes. Note that this PR would not have any real impact on buildingFilterBundle
, since all filters having the same cost so there's no real sorting.Alternatively we've considered making
FilterBundle.IndexBundle
to store all indices and delay the index/matcher partitioning. The major con is that this seems like changing existing behavior too much and it could mean a lot of rewrite to existingFilterBundle
class andFilter.makeFilterBundle
method.Benchmark comparison
query 1
before
after
query 2
before
after
Key changed/added classes in this PR
FilterBundle.Builder
FilterBundle
Filter
BooleanFilter
AndFilter
OrFilter
BitmapColumnIndex
QueryableIndexCursorHolder
This PR has: