Class TaskExecutor

java.lang.Object
org.apache.lucene.search.TaskExecutor

public final class TaskExecutor extends Object
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 Callables 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
    Modifier and Type
    Class
    Description
    private static final class 
    Holds all the sub-tasks that a certain operation gets split into as it gets parallelized and exposes the ability to invoke such tasks and wait for them all to complete their execution and provide their results.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Executor
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a TaskExecutor instance
  • Method Summary

    Modifier and Type
    Method
    Description
    <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.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • executor

      private final Executor executor
  • Constructor Details

    • TaskExecutor

      public TaskExecutor(Executor executor)
      Creates a TaskExecutor instance
      Parameters:
      executor - the executor to be used for running tasks concurrently
  • Method Details

    • invokeAll

      public <T> List<T> invokeAll(Collection<Callable<T>> callables) throws IOException
      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.
      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
    • toString

      public String toString()
      Overrides:
      toString in class Object