org.apache.derby.agg

## Interface Aggregator<V,R,A extends Aggregator<V,R,A>>

- All Superinterfaces:
    Serializable

      public interface Aggregator<V,R,A extends Aggregator<V,R,A>>
      extends Serializable

  Behavior of a user-defined Derby aggregator. Aggregates values of type V and returns a result of type R. In addition to the methods in the interface, implementing classes must have a 0-arg public constructor.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `accumulate(V value)` Accumulate the next scalar value
    `void` | `init()` Initialize the Aggregator
    `void` | `merge(A otherAggregator)` For merging another partial result into this Aggregator.
    `R` | `terminate()` Return the result scalar value

- - ### Method Detail

    - #### init

          void init()

      Initialize the Aggregator

    - #### accumulate

          void accumulate(V value)

      Accumulate the next scalar value

    - #### merge

          void merge(A otherAggregator)

      For merging another partial result into this Aggregator. This lets the SQL interpreter divide the incoming rows into subsets, aggregating each subset in isolation, and then merging the partial results together. This method can be called when performing a grouped aggregation with a large number of groups. While processing such a query, Derby may write intermediate grouped results to disk. The intermediate results may be retrieved and merged with later results if Derby encounters later rows which belong to groups whose intermediate results have been written to disk. This situation can occur with a query like the following:

           select a, mode( b ) from mode_inputs group by a order by a

    - #### terminate

          R terminate()

      Return the result scalar value

Apache Derby 10.13 API Documentation - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.