Add PriorityQueue#addNoShift, and use it in DisjunctionMaxBulkScorer's constructor.#15823
Open
vsop-479 wants to merge 1 commit intoapache:mainfrom
Open
Add PriorityQueue#addNoShift, and use it in DisjunctionMaxBulkScorer's constructor.#15823vsop-479 wants to merge 1 commit intoapache:mainfrom
vsop-479 wants to merge 1 commit intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a specialized PriorityQueue insertion method that skips heap adjustment and uses it to optimize initialization of DisjunctionMaxBulkScorer, where all initial queue keys are equal (next == 0).
Changes:
- Add
PriorityQueue#addNoShift(T)to append elements withoutupHeap. - Use
addNoShiftwhen building the scorer queue inDisjunctionMaxBulkScorer’s constructor. - Minor local refactor in
DisjunctionMaxBulkScorer.collectto reuse the computeddelta.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java | Adds addNoShift as a new insertion API that bypasses heap restoration. |
| lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxBulkScorer.java | Uses addNoShift during queue initialization; small delta reuse cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| /** | ||
| * Adds an Object to a PriorityQueue without upHeap. Note: only use it when all elements have a |
Comment on lines
+193
to
+194
| * Adds an Object to a PriorityQueue without upHeap. Note: only use it when all elements have a | ||
| * same value. |
Comment on lines
+197
to
+199
| // TODO: Check element equalsTo lastElement, if we can get the comparator. | ||
|
|
||
| int index = size + 1; |
| * same value. | ||
| */ | ||
| public final void addNoShift(T element) { | ||
| // TODO: Check element equalsTo lastElement, if we can get the comparator. |
| * Adds an Object to a PriorityQueue without upHeap. Note: only use it when all elements have a | ||
| * same value. | ||
| */ | ||
| public final void addNoShift(T element) { |
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.
In DisjunctionMaxBulkScorer's constructor all values to compare is 0, so we can skip the shift.