DocValuesRangeIterator uses SkipBlockRangeIterator as its approximation#15989
Merged
romseygeek merged 3 commits intoapache:mainfrom Apr 28, 2026
Merged
Conversation
This reworks DocValuesRangeIterator so that it always uses a SkipBlockRangeIterator as an approximation if it can, which should improve how it behaves when combined with other two-phase iterators. A nice side-effect is that a lot of the complicated anonymous two-phase iteration implementations that were previously required to use DocValuesRangeIterator are now hidden behind static factory methods, making the iterator simpler to use and less likely to behave badly.
Contributor
Author
|
There are a few obvious follow-ups here, marked as TODO, which were carried over from the previous implementation. But this is big enough as it is and I wanted to keep it reasonably reviewable! The chunky test files were generated by Claude and reviewed by me. |
iverase
reviewed
Apr 28, 2026
iverase
reviewed
Apr 28, 2026
| // Find the next matching block (could be the current block) | ||
| skipper.advance(minValue, maxValue); | ||
| return doc = Math.max(target, skipper.minDocID(0)); | ||
| int nextDoc = Math.max(target, skipper.minDocID(0)); |
Contributor
There was a problem hiding this comment.
Looking at this method above, it can return documents that do not contain values for sparse data.
We only care that the docId is inside a matching block and it is up to the caller to check the block match and act accordingly.
iverase
reviewed
Apr 28, 2026
iverase
reviewed
Apr 28, 2026
…rator-uses-skip-block
romseygeek
added a commit
that referenced
this pull request
Apr 28, 2026
…on (#15989) This reworks DocValuesRangeIterator so that it always uses a SkipBlockRangeIterator as an approximation if it can, which should improve how it behaves when combined with other two-phase iterators. A nice side-effect is that a lot of the complicated anonymous two-phase iteration implementations that were previously required to use DocValuesRangeIterator are now hidden behind static factory methods, making the iterator simpler to use and less likely to behave badly.
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.
This reworks DocValuesRangeIterator so that it always uses a SkipBlockRangeIterator as an approximation if it can, which should improve how it behaves when combined with other two-phase iterators.
A nice side-effect is that a lot of the complicated anonymous two-phase iteration implementations that were previously required to use DocValuesRangeIterator are now hidden behind static factory methods, making the iterator simpler to use and less likely to behave badly.