Apache Lucene open-source search software
LUCENE-2440: add custom ExecutorService to ParallelMultiSearcher
Michael McCandless28a153babc42
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 4942b7f40d8..2fe4021d30d 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -169,6 +169,10 @@ New featuresprocess the payloads of the segments as they are merged (e.g. if one wants torewrite payloads of external indexes as they are added, or of local ones).(Shai Erera, Michael Busch, Mike McCandless)++* LUCENE-2440: Add support for custom ExecutorService in+ ParallelMultiSearcher (Edward Drapkin via Mike McCandless)+======================= Lucene 3.x (not yet released) =======================diff --git a/lucene/src/java/org/apache/lucene/search/ParallelMultiSearcher.java b/lucene/src/java/org/apache/lucene/search/ParallelMultiSearcher.javaindex c5b42077691..595e201c9a0 100644--- a/lucene/src/java/org/apache/lucene/search/ParallelMultiSearcher.java+++ b/lucene/src/java/org/apache/lucene/search/ParallelMultiSearcher.java@@ -42,19 +42,25 @@ import org.apache.lucene.util.ThreadInterruptedException;* or {@link #search(Query,Filter,int)} methods.*/public class ParallelMultiSearcher extends MultiSearcher {-private final ExecutorService executor;private final Searchable[] searchables;private final int[] starts;- /** Creates a {@link Searchable} which searches <i>searchables</i>. */+ /** Creates a {@link Searchable} which searches <i>searchables</i> with the default+ * executor service (a cached thread pool). */public ParallelMultiSearcher(Searchable... searchables) throws IOException {+ this(Executors.newCachedThreadPool(new NamedThreadFactory(ParallelMultiSearcher.class.getSimpleName())), searchables);+ }++ /**+ * Creates a {@link Searchable} which searches <i>searchables</i> with the specified ExecutorService.+ */+ public ParallelMultiSearcher(ExecutorService executor, Searchable... searchables) throws IOException {super(searchables);this.searchables = searchables;this.starts = getStarts();- executor = Executors.newCachedThreadPool(new NamedThreadFactory(this.getClass().getSimpleName()));+ this.executor = executor;}-/*** Executes each {@link Searchable}'s docFreq() in its own thread and waits for each search to complete and merge* the results back together.