Skip runs of excluded docs in ReqExclBulkScorer for two-phase clauses#16307
Merged
Conversation
Use TwoPhaseIterator#docIDRunEnd() to skip a run of excluded docs for a two-phase excluded clause, like the plain DocIdSetIterator branch already does, instead of advancing one doc at a time. Clamp to at least upTo+1 since TwoPhaseIterator#docIDRunEnd() defaults to the current doc.
b249629 to
1ea80f8
Compare
romseygeek
approved these changes
Jul 1, 2026
romseygeek
left a comment
Contributor
There was a problem hiding this comment.
since its default returns the current doc.
Is this something we should fix? I can see it being a source of bugs in future
The default returned the current doc ID of the approximation, contradicting
the method's own contract ("one plus the last doc ID of the run") and the
DocIdSetIterator#docIDRunEnd default. Since the run always contains the current
doc, the conservative single-doc default must be docID()+1. Align it and update
the ReqExclBulkScorer comment; the Math.max(upTo+1, ...) clamp stays as defense
against third-party TwoPhaseIterator implementations.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jimczi
added a commit
that referenced
this pull request
Jul 6, 2026
…#16307) Use TwoPhaseIterator#docIDRunEnd() to skip a run of excluded docs for a two-phase excluded clause, like the plain DocIdSetIterator branch already does, instead of advancing one doc at a time. Clamp to at least upTo+1 since TwoPhaseIterator#docIDRunEnd() defaults to the current doc. (cherry picked from commit 446dda9)
Contributor
|
Hi @jimczi - this merge causes a test failure that looks like an off-by-one somewhere. This wasn't present (or was masked?) prior to this change. |
Contributor
|
LLM says this, sorry I can't offer more help. |
Contributor
|
The LLM came up with a single-line fix and a bloated test I don't understand. |
Contributor
Anyone who wants to know next week's lottery numbers just email me now. |
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.
ReqExclBulkScorerskips runs of excluded docs viadocIDRunEnd()only for a plainDocIdSetIteratorexcluded clause; a two-phase clause advances one doc at a time. This usesTwoPhaseIterator#docIDRunEnd()in the two-phase branch too — asDenseConjunctionBulkScoreralready does — clamped to at leastupTo + 1since its default returns the current doc.Speeds up filters with a two-phase excluded clause that matches most docs, e.g. a doc-values
!= vquery. Covered by the existing randomizedTestReqExclBulkScorer#testRandomTwoPhase(itsRandomTwoPhaseViewoverridesdocIDRunEnd()).