Skip to content

used WANDScorer.advanceShallow() to enable block-max optimizations when nested in conjunctions#16220

Open
iprithv wants to merge 2 commits into
apache:mainfrom
iprithv:wandscorer-advanceshallow
Open

used WANDScorer.advanceShallow() to enable block-max optimizations when nested in conjunctions#16220
iprithv wants to merge 2 commits into
apache:mainfrom
iprithv:wandscorer-advanceshallow

Conversation

@iprithv

@iprithv iprithv commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

used WANDScorer.advanceShallow() so that WAND queries nested inside conjunctions can skip blocks instead of treating the entire segment as one giant block.

@github-actions github-actions Bot added this to the 10.5.0 milestone Jun 8, 2026

@costin costin left a comment

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.

LGTM

for (Scorer scorer : allScorers) {
if (scorer.docID() < target) {
scorer.advanceShallow(target);
if (scorer.docID() <= target) {

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.

Nit: the old code used < target (skip propagation when already at target), this uses <= target. The <= is correct here since you need the return value from advanceShallow even when docID() == target, but worth a one-line comment explaining the change from < to <= (vs a typo).

if (scorer.docID() <= target) {
newUpTo = Math.min(newUpTo, scorer.advanceShallow(target));
} else if (scorer.docID() != DocIdSetIterator.NO_MORE_DOCS) {
newUpTo = Math.min(newUpTo, scorer.docID() - 1);

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.

Consider return (target <= upTo) ? Math.min(upTo, newUpTo) : newUpTo;

Otherwise the early return discards the freshly computed newUpTo, which could be tighter than upTo.
Always returning the previous upTo is safe (advanceShallow contract allows over-approximation), but it means the parent gets a looser bound than necessary hence the suggested conditional.

@iprithv iprithv force-pushed the wandscorer-advanceshallow branch from d245ee3 to fc65e6e Compare June 29, 2026 22:40
@iprithv iprithv force-pushed the wandscorer-advanceshallow branch from fc65e6e to 3175d3f Compare June 29, 2026 22:41
@iprithv

iprithv commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

moved entry of changes.txt under 10.6

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.

3 participants