Skip to content

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

Merged
jimczi merged 3 commits into
apache:mainfrom
iprithv:wandscorer-advanceshallow
Jul 29, 2026
Merged

used WANDScorer.advanceShallow() to enable block-max optimizations when nested in conjunctions#16220
jimczi merged 3 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 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

moved entry of changes.txt under 10.6

@iprithv
iprithv force-pushed the wandscorer-advanceshallow branch from 3175d3f to ccdec7d Compare July 8, 2026 14:57
@github-actions

Copy link
Copy Markdown
Contributor

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution!

@github-actions github-actions Bot added the Stale label Jul 23, 2026
@jimczi

jimczi commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

LGTM, thanks for working on this! Nice to have nested WAND skip blocks instead of treating the whole segment as one. Will merge soon.

Comment thread lucene/core/src/java/org/apache/lucene/search/WANDScorer.java Outdated
@github-actions github-actions Bot removed the Stale label Jul 27, 2026
@iprithv
iprithv requested a review from jimczi July 27, 2026 18:21
@jimczi
jimczi merged commit 62f29b6 into apache:main Jul 29, 2026
12 checks passed
jimczi pushed a commit that referenced this pull request Jul 29, 2026
…en nested in conjunctions (#16220)

Implement WANDScorer.advanceShallow() to enable block-max optimizations when nested in conjunctions

(cherry picked from commit 62f29b6)
@jimczi

jimczi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Merged and backported to 10x, thanks @iprithv !

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.

4 participants