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/06/09 07:14:53 UTC

(lucene) branch main updated: Remove deprecated usages of search(Query, Collector) from monitor module (#16197)

This is an automated email from the ASF dual-hosted git repository.

javanna 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 3798b540a74 Remove deprecated usages of search(Query, Collector) from monitor module (#16197)
3798b540a74 is described below

commit 3798b540a7433dbf328649ce5bff7117a7737bcc
Author: Luca Cavanna <ja...@apache.org>
AuthorDate: Tue Jun 9 09:14:46 2026 +0200

    Remove deprecated usages of search(Query, Collector) from monitor module (#16197)
    
    This is merely removing the deprecated usages, without introducing search concurrency to monitor.
    The searcher creation is all internal to monitor and there is currently no way for users to
    provide an executor to parallelize searches. Should we want to do that in the future, a larger
    refactor is needed to support inter-segment concurrency.
    
    Relates to #12892
---
 lucene/CHANGES.txt                                     |  2 ++
 .../org/apache/lucene/monitor/ReadonlyQueryIndex.java  | 18 +++++++++++++++++-
 .../org/apache/lucene/monitor/WritableQueryIndex.java  | 18 +++++++++++++++++-
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 4912aa5e01f..31d20695536 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -610,6 +610,8 @@ Other
 * GITHUB#16178: Simplify how we collect hits in the LRU cache from a DocIdStream into a RoaringDocIdSet.
   (Ignacio Vera)
 
+* GITHUB#16197: Remove deprecated usages of search(Query, Collector) from monitor module. (Luca Cavanna)
+
 ======================= Lucene 10.4.0 =======================
 
 API Changes
diff --git a/lucene/monitor/src/java/org/apache/lucene/monitor/ReadonlyQueryIndex.java b/lucene/monitor/src/java/org/apache/lucene/monitor/ReadonlyQueryIndex.java
index 35a8e069821..1a7891c8d80 100644
--- a/lucene/monitor/src/java/org/apache/lucene/monitor/ReadonlyQueryIndex.java
+++ b/lucene/monitor/src/java/org/apache/lucene/monitor/ReadonlyQueryIndex.java
@@ -18,10 +18,12 @@
 package org.apache.lucene.monitor;
 
 import java.io.IOException;
+import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.search.CollectorManager;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreMode;
@@ -79,7 +81,21 @@ class ReadonlyQueryIndex extends QueryIndex {
           queryBuilder.buildQuery(
               termFilters.get(searcher.getIndexReader().getReaderCacheHelper().getKey()));
       buildTime = System.nanoTime() - buildTime;
-      searcher.search(query, collector);
+      searcher.search(
+          query,
+          new CollectorManager<LazyMonitorQueryCollector, Void>() {
+            @Override
+            public LazyMonitorQueryCollector newCollector() {
+              return collector;
+            }
+
+            @Override
+            public Void reduce(Collection<LazyMonitorQueryCollector> collectors) {
+              assert collectors.size() == 1
+                  : "QueryCollector needs to be made thread-safe before an executor can be provided to the index searcher used by monitor";
+              return null;
+            }
+          });
       return buildTime;
     } finally {
       if (searcher != null) {
diff --git a/lucene/monitor/src/java/org/apache/lucene/monitor/WritableQueryIndex.java b/lucene/monitor/src/java/org/apache/lucene/monitor/WritableQueryIndex.java
index 8c5fe84b632..367de7653a6 100644
--- a/lucene/monitor/src/java/org/apache/lucene/monitor/WritableQueryIndex.java
+++ b/lucene/monitor/src/java/org/apache/lucene/monitor/WritableQueryIndex.java
@@ -19,6 +19,7 @@ package org.apache.lucene.monitor;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -38,6 +39,7 @@ import org.apache.lucene.document.StringField;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.search.CollectorManager;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.Query;
@@ -220,7 +222,21 @@ class WritableQueryIndex extends QueryIndex {
           queryBuilder.buildQuery(
               termFilters.get(searcher.getIndexReader().getReaderCacheHelper().getKey()));
       buildTime = System.nanoTime() - buildTime;
-      searcher.search(query, collector);
+      searcher.search(
+          query,
+          new CollectorManager<MonitorQueryCollector, Void>() {
+            @Override
+            public MonitorQueryCollector newCollector() {
+              return collector;
+            }
+
+            @Override
+            public Void reduce(Collection<MonitorQueryCollector> collectors) {
+              assert collectors.size() == 1
+                  : "QueryCollector needs to be made thread-safe before an executor can be provided to the index searcher used by monitor";
+              return null;
+            }
+          });
       return buildTime;
     } finally {
       if (searcher != null) {