You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ch...@apache.org on 2026/05/22 07:51:54 UTC
(lucene) branch main updated: Simplify SortedDocIDMerger.next() (#16073)
This is an automated email from the ASF dual-hosted git repository.
ChrisHegarty pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new f96e2690906 Simplify SortedDocIDMerger.next() (#16073)
f96e2690906 is described below
commit f96e2690906683d76a70cdde106e97996767cd52
Author: Tim Brooks <ti...@timbrooks.org>
AuthorDate: Fri May 22 01:51:47 2026 -0600
Simplify SortedDocIDMerger.next() (#16073)
The else if (queue.size() > 0) guard is always true when reached:
an empty queue sets queueMinDocID to NO_MORE_DOCS, so any valid nextDoc
satisfies nextDoc < queueMinDocID and takes the fast path first. Replace
with else and add a comment explaining why the queue is never empty
at that point.
---
lucene/CHANGES.txt | 2 ++
lucene/core/src/java/org/apache/lucene/index/DocIDMerger.java | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index b03e7fda485..0fd72dff192 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -496,6 +496,8 @@ Other
* GITHUB#16090: Make CollectorMemoryTracker instance members final. (Luca Cavanna)
+* GITHUB#16073: Simplify SortedDocIDMerger.next(). (Tim Brooks)
+
======================= Lucene 10.4.0 =======================
API Changes
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocIDMerger.java b/lucene/core/src/java/org/apache/lucene/index/DocIDMerger.java
index bf01fcdd497..463dfee7ff9 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocIDMerger.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocIDMerger.java
@@ -197,7 +197,9 @@ public abstract class DocIDMerger<T extends DocIDMerger.Sub> {
} else {
current = queue.pop();
}
- } else if (queue.size() > 0) {
+ } else {
+ // queue cannot be empty here: if it were, queueMinDocID == NO_MORE_DOCS, and any valid
+ // nextDoc would satisfy nextDoc < queueMinDocID, taking the fast path above
assert queueMinDocID == queue.top().mappedDocID;
assert nextDoc > queueMinDocID;
T newCurrent = queue.top();