Class ReduceDriver<T>

  • All Implemented Interfaces:
    Driver<ReduceFunction<T>,​T>

    public class ReduceDriver<T>
    extends Object
    implements Driver<ReduceFunction<T>,​T>
    Reduce driver which is executed by a Task Manager. The task has a single input and one or multiple outputs. It is provided with a ReduceFunction implementation.

    The ReduceDriver creates an iterator over all records from its input. The iterator returns all records grouped by their key. The elements are handed pairwise to the reduce() method of the ReduceFunction.

    See Also:
    ReduceFunction
    • Constructor Detail

      • ReduceDriver

        public ReduceDriver()
    • Method Detail

      • getNumberOfInputs

        public int getNumberOfInputs()
        Description copied from interface: Driver
        Gets the number of inputs that the task has.
        Specified by:
        getNumberOfInputs in interface Driver<ReduceFunction<T>,​T>
        Returns:
        The number of inputs.
      • getStubType

        public Class<ReduceFunction<T>> getStubType()
        Description copied from interface: Driver
        Gets the class of the stub type that is run by this task. For example, a MapTask should return MapFunction.class.
        Specified by:
        getStubType in interface Driver<ReduceFunction<T>,​T>
        Returns:
        The class of the stub type run by the task.
      • getNumberOfDriverComparators

        public int getNumberOfDriverComparators()
        Description copied from interface: Driver
        Gets the number of comparators required for this driver.
        Specified by:
        getNumberOfDriverComparators in interface Driver<ReduceFunction<T>,​T>
        Returns:
        The number of comparators required for this driver.
      • prepare

        public void prepare()
                     throws Exception
        Description copied from interface: Driver
        This method is called before the user code is opened. An exception thrown by this method signals failure of the task.
        Specified by:
        prepare in interface Driver<ReduceFunction<T>,​T>
        Throws:
        Exception - Exceptions may be forwarded and signal task failure.
      • run

        public void run()
                 throws Exception
        Description copied from interface: Driver
        The main operation method of the task. It should call the user code with the data subsets until the input is depleted.
        Specified by:
        run in interface Driver<ReduceFunction<T>,​T>
        Throws:
        Exception - Any exception thrown by this method signals task failure. Because exceptions in the user code typically signal situations where this instance in unable to proceed, exceptions from the user code should be forwarded.
      • cleanup

        public void cleanup()
        Description copied from interface: Driver
        This method is invoked in any case (clean termination and exception) at the end of the tasks operation.
        Specified by:
        cleanup in interface Driver<ReduceFunction<T>,​T>
      • cancel

        public void cancel()
        Description copied from interface: Driver
        This method is invoked when the driver must aborted in mid processing. It is invoked asynchronously by a different thread.
        Specified by:
        cancel in interface Driver<ReduceFunction<T>,​T>