org.eclipse.viatra.query.runtime.matchers.psystem.aggregations

## Interface IMultisetAggregationOperator<Domain,Accumulator,AggregateResult>

- Type Parameters:
    `Domain` - the type of elements to be aggregated.
    `Accumulator` - the type used to store the interim results of the aggregate computation, that may be incrementally refreshed upon updates to the multiset, and that can easily yield the final result.
    `AggregateResult` - the type of the final result of the aggregation to be output.
  All Known Implementing Classes:
    AbstractMemorylessAggregationOperator, AbstractMultisetAggregationOperator, DoubleSumOperator, ExtremumOperator, IntegerSumOperator, LongSumOperator

      public interface IMultisetAggregationOperator<Domain,Accumulator,AggregateResult>

  A single column aggregator is used to incrementally compute the aggregate of a multiset of values according to an aggregator operator.

  The operator provides two methods of computation:

  - Stateless aggregation of an explicit multiset, provided by `#aggregateStatelessly(Collection)`.
  - Incremental aggregation, provided by `createNeutral()`, `update(Object, Object, boolean)`, `isNeutral(Object)`, `getAggregate(Object)`.

  In case of incremental computation, the aggregable multiset is conceptual; it is not represented by an explicit Collection object, but its update operations are tracked.

  In case of incremental computation, internal results, potentially distinct from the final aggregate result, may be stored in a helper data structure called accumulator. The goal of this distinction is that the final result may not be sufficient for incremental updates (see e.g. `ExtremumOperator`).

  Since:
    1.4
  No Implement:
    This interface is not intended to be implemented by clients. Extend `AbstractMultisetAggregationOperator` instead.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Accumulator` | `createNeutral()`
    `AggregateResult` | `getAggregate(Accumulator result)`
    `java.lang.String` | `getName()` A name or identifier of the operator.
    `java.lang.String` | `getShortDescription()` A textual description of the operator.
    `boolean` | `isNeutral(Accumulator result)`
    `Accumulator` | `update(Accumulator oldResult, Domain updateValue, boolean isInsertion)`

- - ### Method Detail

    - #### getShortDescription

          java.lang.String getShortDescription()

      A textual description of the operator.

    - #### getName

          java.lang.String getName()

      A name or identifier of the operator.

    - #### createNeutral

          Accumulator createNeutral()

      Returns:
        the neutral element, i.e. the interim result of aggregating an empty multiset.

    - #### isNeutral

          boolean isNeutral(Accumulator result)

      Returns:
        true if the interim result is equivalent to the neutral element, as if there are no values in the multiset. Must return true if the multiset is empty.

    - #### update

          Accumulator update(Accumulator oldResult,
                             Domain updateValue,
                             boolean isInsertion)

      Returns:
        an updated intermediate result, changed to reflect that a given object was added to / removed from the multiset (as indicated by the parameter isInsertion)

    - #### getAggregate

          AggregateResult getAggregate(Accumulator result)

      Returns:
        the aggregate result obtained from the given intermediate result. May be null to indicate that the current multiset cannot be aggregated (e.g. 0 elements have no minimum).