public interface Accumulator
The running state of one aggregate over one group.

A fresh accumulator is created per group, fed one call to accumulate(java.util.List<com.darkcollective.relix.value.Value>) per row, and asked once for its result. It is not required to be thread-safe: the engine gives each group its own.

Arguments arrive as a list because an aggregate is not always over a single value — a "row with the maximum" reduction takes the ranking expression and the one to yield from it, and a correlation takes two. Passing a list rather than a row keeps the engine's representation of a row out of the SPI entirely.

NULL handling is declared, not implemented here: when the signature says the aggregate skips NULLs, the engine drops those rows before accumulate sees them.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accumulate(List<Value> arguments)
    Folds one row's argument values into the running state.
    The aggregate's value for the group, read once after the last row.
    default void
    Folds another accumulator's state into this one, when the aggregate can be computed in parts and combined.
  • Method Details

    • accumulate

      void accumulate(List<Value> arguments)
      Folds one row's argument values into the running state.
      Parameters:
      arguments - the row's argument values, in call order; never null
    • finish

      Value finish()
      The aggregate's value for the group, read once after the last row.

      An accumulator that saw no rows returns the empty-group answer — NULL for the SQL reducers, zero for a count, an empty array for a gathering aggregate.

      Returns:
      the group's result; never null
    • merge

      default void merge(Accumulator other)
      Folds another accumulator's state into this one, when the aggregate can be computed in parts and combined.

      The default declines, which is what an aggregate that cannot be split says. Implementing it is what allows a group to be accumulated in more than one place and the parts joined.

      Parameters:
      other - an accumulator of the same aggregate, whose state is folded into this
      Throws:
      UnsupportedOperationException - if this aggregate cannot be combined from parts