You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "James Xu (JIRA)" <ji...@apache.org> on 2017/05/10 02:40:04 UTC

[jira] [Created] (CALCITE-1783) Support merge method in AggregateFunction

James Xu created CALCITE-1783:
---------------------------------

             Summary: Support merge method in AggregateFunction
                 Key: CALCITE-1783
                 URL: https://issues.apache.org/jira/browse/CALCITE-1783
             Project: Calcite
          Issue Type: New Feature
            Reporter: James Xu
            Assignee: Julian Hyde


I was implementing the UDAF for BEAM SQL using Calcite, Since BEAM is used in big data processing where aggregate functions will be implemented using distributed algorithms. Then the `merge` method is a must to support UDAF in BEAM, the corresponding aggregator interface in BEAM is `CombineFn`:

{code:java}
  public abstract static class CombineFn<InputT, AccumT, OutputT>
      extends AbstractGlobalCombineFn<InputT, AccumT, OutputT> {

    /**
     * Returns a new, mutable accumulator value, representing the accumulation of zero input values.
     */
    public abstract AccumT createAccumulator();

    /**
     * Adds the given input value to the given accumulator, returning the
     * new accumulator value.
     *
     * <p>For efficiency, the input accumulator may be modified and returned.
     */
    public abstract AccumT addInput(AccumT accumulator, InputT input);

    /**
     * Returns an accumulator representing the accumulation of all the
     * input values accumulated in the merging accumulators.
     *
     * <p>May modify any of the argument accumulators.  May return a
     * fresh accumulator, or may return one of the (modified) argument
     * accumulators.
     */
    public abstract AccumT mergeAccumulators(Iterable<AccumT> accumulators);

    /**
     * Returns the output value that is the result of combining all
     * the input values represented by the given accumulator.
     */
    public abstract OutputT extractOutput(AccumT accumulator);
  }
{code}

mergeAccumulators is the analogue in BEAM for `merge`.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)