org.eclipse.viatra.query.runtime.rete.aggregation

## Class ColumnAggregatorNode<Domain,Accumulator,AggregateResult>

- java.lang.Object
- - org.eclipse.viatra.query.runtime.rete.network.BaseNode
  - - org.eclipse.viatra.query.runtime.rete.network.StandardNode
    - - org.eclipse.viatra.query.runtime.rete.single.SingleInputNode
      - - org.eclipse.viatra.query.runtime.rete.aggregation.ColumnAggregatorNode<Domain,Accumulator,AggregateResult>

- All Implemented Interfaces:
    IAggregatorNode, MonotonicityAwareReceiver, Node, Receiver, RederivableNode, Supplier, Tunnel, Clearable

      public class ColumnAggregatorNode<Domain,Accumulator,AggregateResult>
      extends SingleInputNode
      implements Clearable, IAggregatorNode, RederivableNode, MonotonicityAwareReceiver

  Groups incoming tuples by the given mask, and aggregates values at a specific index in each group.

  Direct children are nor supported, use via outer join indexers instead.

  Since:
    1.4

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected TupleMask` | `columnMask`
    `protected boolean` | `deleteRederiveEvaluation`
    `protected TupleMask` | `groupMask`
    `protected java.util.Map<Tuple,Accumulator>` | `memory`
    `protected IMultisetAggregationOperator<Domain,Accumulator,AggregateResult>` | `operator`
    `protected IPosetComparator` | `posetComparator`
    `protected java.util.Map<Tuple,Accumulator>` | `rederivableMemory`
    `protected IQueryRuntimeContext` | `runtimeContext`
    `protected int` | `sourceWidth`

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.rete.single.SingleInputNode

      `mailbox, parent`

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.rete.network.StandardNode

      `children`

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.rete.network.BaseNode

      `nodeId, reteContainer, tag, traceInfos`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ColumnAggregatorNode(ReteContainer reteContainer, IMultisetAggregationOperator<Domain,Accumulator,AggregateResult> operator, boolean deleteRederiveEvaluation, TupleMask groupMask, TupleMask columnMask, IPosetComparator posetComparator)` Creates a new column aggregator node.
    `ColumnAggregatorNode(ReteContainer reteContainer, IMultisetAggregationOperator<Domain,Accumulator,AggregateResult> operator, TupleMask groupMask, int aggregatedColumn)` Creates a new column aggregator node.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `appendChild(Receiver receiver)` appends a receiver that will continously receive insert and revoke updates from this supplier
    `void` | `clear()` Clear all partial matchings stored in memory
    `protected Accumulator` | `getAccumulator(Tuple key, java.util.Map<Tuple,Accumulator> memory)`
    `AggregateResult` | `getAggregateResult(Tuple key)`
    `Tuple` | `getAggregateTuple(Tuple key)`
    `Indexer` | `getAggregatorOuterIdentityIndexer(int resultPositionInSignature)`
    `Indexer` | `getAggregatorOuterIndexer()`
    `TupleMask` | `getCoreMask()`
    `protected Accumulator` | `getMainAccumulator(Tuple key)`
    `IPosetComparator` | `getPosetComparator()`
    `TupleMask` | `getPosetMask()`
    `protected Accumulator` | `getRederivableAccumulator(Tuple key)`
    `protected Mailbox` | `instantiateMailbox()` Instantiates the `Mailbox` of this receiver.
    `void` | `propagate(Tuple group, AggregateResult oldValue, AggregateResult newValue)`
    `void` | `pullInto(java.util.Collection<Tuple> collector)` pulls the contents of this object in this particular moment into a target collection
    `void` | `rederiveOne()` The method is called by the `ReteContainer` to re-derive tuples after the normal messages have been delivered and consumed.
    `protected boolean` | `storeIfNotNeutral(Tuple key, Accumulator accumulator, java.util.Map<Tuple,Accumulator> memory)` Returns true if the accumulator was stored, false otherwise.
    `protected Tuple` | `tupleFromAggregateResult(Tuple groupTuple, AggregateResult aggregateResult)`
    `void` | `update(Direction direction, Tuple update)` updates the receiver with a newly found or lost partial matching
    `void` | `update(Direction direction, Tuple update, boolean monotone)` Updates the receiver with a newly found or lost partial matching also providing information whether the update is a monotone change or not.
    `protected void` | `updateDefault(Direction direction, Tuple update)`
    `protected void` | `updateWithDeleteAndRederive(Direction direction, Tuple update, boolean monotone)`

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.rete.single.SingleInputNode

      `appendParent, assignTraceInfo, getMailbox, getParents, propagatePullInto, removeParent`

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.rete.network.StandardNode

      `constructIndex, getPulledContents, getReceivers, issueError, propagateUpdate, removeChild`

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.rete.network.BaseNode

      `acceptPropagatedTraceInfo, getContainer, getNodeId, getTag, getTraceInfoPatternsEnumerated, getTraceInfos, setTag, toString, toStringCore`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.viatra.query.runtime.rete.network.Receiver

      `appendParent, getMailbox, getParents, removeParent`

    - ### Methods inherited from interface org.eclipse.viatra.query.runtime.rete.network.Node

      `acceptPropagatedTraceInfo, assignTraceInfo, getContainer, getNodeId, getTag, getTraceInfos, setTag`

    - ### Methods inherited from interface org.eclipse.viatra.query.runtime.rete.network.Supplier

      `constructIndex, getPulledContents, getReceivers, removeChild`

- - ### Field Detail

    - #### operator

          protected final IMultisetAggregationOperator<Domain,Accumulator,AggregateResult> operator

      Since:
        1.6

    - #### groupMask

          protected final TupleMask groupMask

      Since:
        1.6

    - #### columnMask

          protected final TupleMask columnMask

      Since:
        1.6

    - #### posetComparator

          protected final IPosetComparator posetComparator

      Since:
        1.6

    - #### sourceWidth

          protected final int sourceWidth

      Since:
        1.6

    - #### runtimeContext

          protected final IQueryRuntimeContext runtimeContext

      Since:
        1.6

    - #### deleteRederiveEvaluation

          protected final boolean deleteRederiveEvaluation

      Since:
        1.6

    - #### memory

          protected final java.util.Map<Tuple,Accumulator> memory

      Since:
        1.6

    - #### rederivableMemory

          protected final java.util.Map<Tuple,Accumulator> rederivableMemory

      Since:
        1.6

  - ### Constructor Detail

    - #### ColumnAggregatorNode

          public ColumnAggregatorNode(ReteContainer reteContainer,
                                      IMultisetAggregationOperator<Domain,Accumulator,AggregateResult> operator,
                                      boolean deleteRederiveEvaluation,
                                      TupleMask groupMask,
                                      TupleMask columnMask,
                                      IPosetComparator posetComparator)

      Creates a new column aggregator node.
      Parameters:
        `reteContainer` - the RETE container of the node
        `operator` - the aggregation operator
        `deleteRederiveEvaluation` - true if the node should run in DRED mode, false otherwise
        `groupMask` - the mask that masks a tuple to obtain the key that we are grouping-by
        `columnMask` - the mask that masks a tuple to obtain the tuple element(s) that we are aggregating over
        `posetComparator` - the poset comparator for the column, if known, otherwise it can be null
      Since:
        1.6

    - #### ColumnAggregatorNode

          public ColumnAggregatorNode(ReteContainer reteContainer,
                                      IMultisetAggregationOperator<Domain,Accumulator,AggregateResult> operator,
                                      TupleMask groupMask,
                                      int aggregatedColumn)

      Creates a new column aggregator node.
      Parameters:
        `reteContainer` - the RETE container of the node
        `operator` - the aggregation operator
        `groupMask` - the mask that masks a tuple to obtain the key that we are grouping-by
        `aggregatedColumn` - the index of the column that the aggregator node is aggregating over

  - ### Method Detail

    - #### instantiateMailbox

          protected Mailbox instantiateMailbox()

      Description copied from class: `SingleInputNode`
      Instantiates the `Mailbox` of this receiver. Subclasses may override this method to provide their own mailbox implementation.
      Overrides:
        `instantiateMailbox` in class `SingleInputNode`
      Returns:
        the mailbox

    - #### getCoreMask

          public TupleMask getCoreMask()

      Specified by:
        `getCoreMask` in interface `MonotonicityAwareReceiver`

    - #### getPosetMask

          public TupleMask getPosetMask()

      Specified by:
        `getPosetMask` in interface `MonotonicityAwareReceiver`

    - #### getPosetComparator

          public IPosetComparator getPosetComparator()

      Specified by:
        `getPosetComparator` in interface `MonotonicityAwareReceiver`

    - #### pullInto

          public void pullInto(java.util.Collection<Tuple> collector)

      Description copied from interface: `Supplier`
      pulls the contents of this object in this particular moment into a target collection
      Specified by:
        `pullInto` in interface `Supplier`

    - #### appendChild

          public void appendChild(Receiver receiver)

      Description copied from interface: `Supplier`
      appends a receiver that will continously receive insert and revoke updates from this supplier
      Specified by:
        `appendChild` in interface `Supplier`
      Overrides:
        `appendChild` in class `StandardNode`

    - #### getAggregatorOuterIndexer

          public Indexer getAggregatorOuterIndexer()

      Specified by:
        `getAggregatorOuterIndexer` in interface `IAggregatorNode`

    - #### getAggregatorOuterIdentityIndexer

          public Indexer getAggregatorOuterIdentityIndexer(int resultPositionInSignature)

      Specified by:
        `getAggregatorOuterIdentityIndexer` in interface `IAggregatorNode`

    - #### rederiveOne

          public void rederiveOne()

      Description copied from interface: `RederivableNode`
      The method is called by the `ReteContainer` to re-derive tuples after the normal messages have been delivered and consumed. The re-derivation process may trigger the creation and delivery of further messages and further re-derivation rounds.
      Specified by:
        `rederiveOne` in interface `RederivableNode`

    - #### update

          public void update(Direction direction,
                             Tuple update,
                             boolean monotone)

      Description copied from interface: `MonotonicityAwareReceiver`
      Updates the receiver with a newly found or lost partial matching also providing information whether the update is a monotone change or not.
      Specified by:
        `update` in interface `MonotonicityAwareReceiver`
      Parameters:
        `direction` - the direction of the update
        `update` - the update tuple
        `monotone` - true if the update is monotone, false otherwise

    - #### update

          public void update(Direction direction,
                             Tuple update)

      Description copied from interface: `Receiver`
      updates the receiver with a newly found or lost partial matching
      Specified by:
        `update` in interface `Receiver`

    - #### updateDefault

          protected void updateDefault(Direction direction,
                                       Tuple update)

      Since:
        1.6

    - #### updateWithDeleteAndRederive

          protected void updateWithDeleteAndRederive(Direction direction,
                                                     Tuple update,
                                                     boolean monotone)

      Since:
        1.6

    - #### propagate

          public void propagate(Tuple group,
                                AggregateResult oldValue,
                                AggregateResult newValue)

      Since:
        1.6

    - #### clear

          public void clear()

      Description copied from interface: `Clearable`
      Clear all partial matchings stored in memory
      Specified by:
        `clear` in interface `Clearable`

    - #### storeIfNotNeutral

          protected boolean storeIfNotNeutral(Tuple key,
                                              Accumulator accumulator,
                                              java.util.Map<Tuple,Accumulator> memory)

      Returns true if the accumulator was stored, false otherwise.
      Since:
        1.6

    - #### getAggregateTuple

          public Tuple getAggregateTuple(Tuple key)

    - #### getAggregateResult

          public AggregateResult getAggregateResult(Tuple key)

    - #### getMainAccumulator

          protected Accumulator getMainAccumulator(Tuple key)

      Since:
        1.6

    - #### getRederivableAccumulator

          protected Accumulator getRederivableAccumulator(Tuple key)

      Since:
        1.6

    - #### getAccumulator

          protected Accumulator getAccumulator(Tuple key,
                                               java.util.Map<Tuple,Accumulator> memory)

      Since:
        1.6

    - #### tupleFromAggregateResult

          protected Tuple tupleFromAggregateResult(Tuple groupTuple,
                                                   AggregateResult aggregateResult)