Skip to content

DocValuesRangeIterator uses SkipBlockRangeIterator as its approximation#15989

Merged
romseygeek merged 3 commits intoapache:mainfrom
romseygeek:skipper/doc-range-iterator-uses-skip-block
Apr 28, 2026
Merged

DocValuesRangeIterator uses SkipBlockRangeIterator as its approximation#15989
romseygeek merged 3 commits intoapache:mainfrom
romseygeek:skipper/doc-range-iterator-uses-skip-block

Conversation

@romseygeek
Copy link
Copy Markdown
Contributor

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 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.
@romseygeek romseygeek requested a review from iverase April 27, 2026 16:19
@romseygeek romseygeek self-assigned this Apr 27, 2026
@romseygeek
Copy link
Copy Markdown
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.

// 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));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@iverase iverase left a comment

Choose a reason for hiding this comment

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

LGTM.

@github-actions github-actions Bot added this to the 10.5.0 milestone Apr 28, 2026
@romseygeek romseygeek merged commit 9582ee9 into apache:main Apr 28, 2026
13 checks passed
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.
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