You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2026/04/29 19:39:48 UTC
(lucene) branch branch_10x updated: Skip heavy TreeSet opts for the first group in SearchGroup#merge (#15896)
This is an automated email from the ASF dual-hosted git repository.
jainankitk pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_10x by this push:
new 43efe7b6c2f Skip heavy TreeSet opts for the first group in SearchGroup#merge (#15896)
43efe7b6c2f is described below
commit 43efe7b6c2feda1498bb9f58b3b34cc5084731ab
Author: gaobinlong <gb...@amazon.com>
AuthorDate: Thu Apr 30 03:36:55 2026 +0800
Skip heavy TreeSet opts for the first group in SearchGroup#merge (#15896)
Signed-off-by: Binlong Gao <gb...@amazon.com>
---
lucene/CHANGES.txt | 2 ++
.../java/org/apache/lucene/search/grouping/SearchGroup.java | 10 +++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index aff368fabb9..84fed476090 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -84,6 +84,8 @@ Optimizations
* GITHUB#15779: Improve BytesRefHash.add performance by optimize rehash operation (tyronecai)
+* GITHUB#15896: Skip heavy TreeSet opts for the first group in SearchGroup#merge (Binlong Gao)
+
* GITHUB#15886: Cache frozen FieldType to skip redundant schema validation. (Tim Brooks)
* GITHUB#15942: Skip max score computation when sorting by relevance in BlockGroupingCollector (Binlong Gao)
diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java b/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
index 863924d42c2..36bab96b4f4 100644
--- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
+++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/SearchGroup.java
@@ -249,13 +249,17 @@ public class SearchGroup<T> {
// System.out.println(" competes=" + competes);
if (competes) {
- // Group's sort changed -- remove & re-insert
- if (mergedGroup.inQueue) {
+ // Group's sort changed -- remove & re-insert, update first group in place for
+ // efficiency
+ boolean skipHeavyOps = queue.first() == mergedGroup;
+ if (mergedGroup.inQueue && !skipHeavyOps) {
queue.remove(mergedGroup);
}
mergedGroup.topValues = group.sortValues;
mergedGroup.minShardIndex = shard.shardIndex;
- queue.add(mergedGroup);
+ if (!skipHeavyOps) {
+ queue.add(mergedGroup);
+ }
mergedGroup.inQueue = true;
}
}