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 2025/12/05 22:41:43 UTC

(lucene) branch branch_10x updated: Enabling wrapped collectors in MultiCollector to collectRange (#15475)

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 4b1669f54c0 Enabling wrapped collectors in MultiCollector to collectRange (#15475)
4b1669f54c0 is described below

commit 4b1669f54c03551f977eb9a03ac48ad9234a86d4
Author: Ankit Jain <ja...@apache.org>
AuthorDate: Fri Dec 5 14:16:08 2025 -0800

    Enabling wrapped collectors in MultiCollector to collectRange (#15475)
    
    Signed-off-by: Ankit Jain <ja...@apache.org>
---
 lucene/CHANGES.txt                                   |  2 ++
 .../org/apache/lucene/search/MultiCollector.java     | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 39eda4d0495..5e5dcd6fe39 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -105,6 +105,8 @@ Optimizations
 
 * GITHUB#15406: Improve round trip conversion of ValueSource <-> DoublesValueSource (hossman)
 
+* GITHUB#15475: Enabling wrapped collectors in MultiCollector to collectRange (Ankit Jain)
+
 Bug Fixes
 ---------------------
 * GITHUB#14161: PointInSetQuery's constructor now throws IllegalArgumentException
diff --git a/lucene/core/src/java/org/apache/lucene/search/MultiCollector.java b/lucene/core/src/java/org/apache/lucene/search/MultiCollector.java
index c5372f3170a..e126c63211d 100644
--- a/lucene/core/src/java/org/apache/lucene/search/MultiCollector.java
+++ b/lucene/core/src/java/org/apache/lucene/search/MultiCollector.java
@@ -232,6 +232,26 @@ public class MultiCollector implements Collector {
       }
     }
 
+    @Override
+    public void collectRange(int min, int max) throws IOException {
+      for (int i = 0; i < collectors.length; i++) {
+        final LeafCollector collector = collectors[i];
+        if (collector != null) {
+          try {
+            collector.collectRange(min, max);
+          } catch (
+              @SuppressWarnings("unused")
+              CollectionTerminatedException e) {
+            collectors[i].finish();
+            collectors[i] = null;
+            if (allCollectorsTerminated()) {
+              throw new CollectionTerminatedException();
+            }
+          }
+        }
+      }
+    }
+
     @Override
     public void finish() throws IOException {
       for (LeafCollector collector : collectors) {