java.lang.Object
org.apache.lucene.search.TaskExecutor
Executor wrapper responsible for the execution of concurrent tasks. Used to parallelize search
across segments as well as query rewrite in some cases. Exposes a single
invokeAll(Collection)
method that takes a collection of Callable
s and executes them
concurrently. Once all but one task have been submitted to the executor, it tries to run as many
tasks as possible on the calling thread, then waits for all tasks that have been executed in
parallel on the executor to be completed and then returns a list with the obtained results.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
assertAllFuturesCompleted
(Collection<? extends Future<?>> futures) private static <T> void
cancelAll
(Collection<? extends Future<T>> futures) private static <T> List
<T> collectResults
(List<RunnableFuture<T>> futures) <T> List
<T> invokeAll
(Collection<Callable<T>> callables) Execute all the callables provided as an argument, wait for them to complete and return the obtained results.toString()
-
Field Details
-
executor
-
-
Constructor Details
-
TaskExecutor
Creates a TaskExecutor instance- Parameters:
executor
- the executor to be used for running tasks concurrently
-
-
Method Details
-
invokeAll
Execute all the callables provided as an argument, wait for them to complete and return the obtained results. If an exception is thrown by more than one callable, the subsequent ones will be added as suppressed exceptions to the first one that was caught. Additionally, if one task throws an exception, all other tasks from the same group are cancelled, to avoid needless computation as their results would not be exposed anyways.- Type Parameters:
T
- the return type of the task execution- Parameters:
callables
- the callables to execute- Returns:
- a list containing the results from the tasks execution
- Throws:
IOException
-
collectResults
- Throws:
IOException
-
toString
-
assertAllFuturesCompleted
-
cancelAll
-