Skip to content

Add PriorityQueue#addNoShift, and use it in DisjunctionMaxBulkScorer's constructor.#15823

Open
vsop-479 wants to merge 1 commit intoapache:mainfrom
vsop-479:add_PriorityQueue#addNoShift
Open

Add PriorityQueue#addNoShift, and use it in DisjunctionMaxBulkScorer's constructor.#15823
vsop-479 wants to merge 1 commit intoapache:mainfrom
vsop-479:add_PriorityQueue#addNoShift

Conversation

@vsop-479
Copy link
Contributor

@vsop-479 vsop-479 commented Mar 14, 2026

In DisjunctionMaxBulkScorer's constructor all values to compare is 0, so we can skip the shift.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 without upHeap.
  • Use addNoShift when building the scorer queue in DisjunctionMaxBulkScorer’s constructor.
  • Minor local refactor in DisjunctionMaxBulkScorer.collect to reuse the computed delta.

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) {
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