Interface Accumulator


public interface Accumulator

Stores state during row-reduction as part of a RealizedAggregateExpression. Has methods for applying state from each row (typically a Tuple).

Note that the Accumulator interface is not aware of any types or groups that were used or created when a RealizedAggregateExpression was created - users of the API must only use accumulators with the expressions that created them.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Collect state in to this accumulator
    Combine two accumulators in to one that records the state from both in a manner that gives the same result as if each was reduced against a single Accumulator.
    boolean
     
    Convert accumulated state in to a single value.
  • Method Details

    • combine

      Accumulator combine(Accumulator rhs)

      Combine two accumulators in to one that records the state from both in a manner that gives the same result as if each was reduced against a single Accumulator. Exists to support parallelism in row reductions done as part of the Collector interface.

      The returned object can be a new Accumulator or one of the existing ones. It is assumed that the given accumulators will not be used once this combine operation is completed.

    • accumulate

      void accumulate(Object input)

      Collect state in to this accumulator

    • process

      Object process()

      Convert accumulated state in to a single value. Note that combine and accumulate should not be called again on an Accumulator once process has been called. This makes it safe for an accumulators state to be used in the result or process without fear of mutability bugs been called

    • isEmpty

      boolean isEmpty()
      Returns:
      true if accumulate has never been used. Expect process to return null (or throw an exception) if isEmpty() is true.