Don't union with empty bitmap in the end in Filters.matchPredicate()#3754
Merged
jon-wei merged 1 commit intoapache:masterfrom Dec 7, 2016
Merged
Conversation
…hPredicate() so that it doesn't emit empty bitmap in the end of the iteration, and make it to follow Iterator contract, that is throw NoSuchElementException from next() if there are no more bitmaps
Contributor
|
@leventov have you measured the improvement here? |
Member
Author
|
@gianm no, I didn't. I don't think improvement is significant, because empty bitmaps in compressed representations (concise and roaring) doesn't take much space and cheap to union with. However for roaring it saves one allocation/merge cycle because roaring doesn't support union (and intersection) of more than 2 bitmaps, for making union of many bitmaps it merges them one-by-one. |
Member
Author
|
@gianm thank you very much for quick reviews! |
Contributor
|
👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
I've inspected the graph of bitmap manipulations which are done before processing the query on Druid historical nodes and seen something like this:
(BTW if you want such intronspection capabilities to be commited to Druid sooner please review this: #3693)
It means that we often make unions of something + empty bitmap.
How it is fixed
Optimized
Iterator<ImmutableBitmap>implementation insideFilters.matchPredicate()so that it doesn't emit empty bitmap in the end of the iteration, and make it to followIteratorcontract, that is throwNoSuchElementExceptionfromnext()if there are no more bitmaps.BTW disadvantage of Druid's "anonymous class style" is that it's impossible to add tests to such anonymous interface implementations.