Package 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.AbstractColumnAggregatorNode<Domain,​Accumulator,​AggregateResult>
        - - org.eclipse.viatra.query.runtime.rete.aggregation.ColumnAggregatorNode<Domain,​Accumulator,​AggregateResult>

- All Implemented Interfaces:
    `Clearable`, `IAggregatorNode`, `IGroupable`, `NetworkStructureChangeSensitiveNode`, `Node`, `PosetAwareReceiver`, `Receiver`, `RederivableNode`, `Supplier`, `Tunnel`

      public class ColumnAggregatorNode<Domain,​Accumulator,​AggregateResult>
      extends AbstractColumnAggregatorNode<Domain,​Accumulator,​AggregateResult>
      implements RederivableNode, PosetAwareReceiver

  Timeless implementation of the column aggregator node.

  The node is capable of operating in the delete and re-derive mode. In this mode, it is also possible to equip the node with an `IPosetComparator` to identify monotone changes; thus, ensuring that a fix-point can be reached during the evaluation.

  Since:
    1.4

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.eclipse.viatra.query.runtime.rete.aggregation.AbstractColumnAggregatorNode

      `AbstractColumnAggregatorNode.AggregatorOuterIdentityIndexer, AbstractColumnAggregatorNode.AggregatorOuterIndexer, AbstractColumnAggregatorNode.NetworkStructureChangeSensitiveLogic`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected CommunicationGroup` | `currentGroup` |
    `protected boolean` | `deleteRederiveEvaluation` |
    `protected java.util.Map<Tuple,​Accumulator>` | `memory` |
    `protected IPosetComparator` | `posetComparator` |
    `protected java.util.Map<Tuple,​Accumulator>` | `rederivableMemory` |

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.rete.aggregation.AbstractColumnAggregatorNode

      `aggregatorOuterIdentityIndexers, aggregatorOuterIndexer, columnMask, groupMask, NEUTRAL, operator, runtimeContext, 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

      `childMailboxes, children`

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

      `nodeId, reteContainer, tag, traceInfos`

  - ### Constructor Summary

    Constructors
    Constructor | 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 | Description
    --- | --- | ---
    `void` | `clear()` | Clear all partial matchings stored in memory
    `protected Accumulator` | `getAccumulator​(Tuple key, java.util.Map<Tuple,​Accumulator> memory)` |
    `AggregateResult` | `getAggregateResult​(Tuple group)` |
    `java.util.Map<AggregateResult,​Timeline<Timestamp>>` | `getAggregateResultTimeline​(Tuple key)` |
    `Tuple` | `getAggregateTuple​(Tuple group)` |
    `java.util.Map<Tuple,​Timeline<Timestamp>>` | `getAggregateTupleTimeline​(Tuple key)` |
    `TupleMask` | `getCoreMask()` |
    `CommunicationGroup` | `getCurrentGroup()` |
    `protected Accumulator` | `getMainAccumulator​(Tuple key)` |
    `IPosetComparator` | `getPosetComparator()` |
    `TupleMask` | `getPosetMask()` |
    `protected Accumulator` | `getRederivableAccumulator​(Tuple key)` |
    `protected Mailbox` | `instantiateMailbox()` | Instantiates the `Mailbox` of this receiver.
    `boolean` | `isInDRedMode()` | Returns true if this node actually runs in DRed mode (not necessarily).
    `void` | `rederiveOne()` | The method is called by the `ReteContainer` to re-derive tuples after the normal messages have been delivered and consumed.
    `void` | `setCurrentGroup​(CommunicationGroup currentGroup)` | Sets the current group of the mailbox
    `protected boolean` | `storeIfNotNeutral​(Tuple key, Accumulator accumulator, java.util.Map<Tuple,​Accumulator> memory)` | Returns true if the accumulator was stored, false otherwise.
    `void` | `update​(Direction direction, Tuple update, Timestamp timestamp)` | Updates the receiver with a newly found or lost partial matching.
    `protected void` | `updateDefault​(Direction direction, Tuple update, Timestamp timestamp)` |
    `protected void` | `updateWithDeleteAndRederive​(Direction direction, Tuple update, boolean monotone)` |
    `void` | `updateWithPosetInfo​(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.

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.rete.aggregation.AbstractColumnAggregatorNode

      `appendChild, getAggregatorOuterIdentityIndexer, getAggregatorOuterIndexer, getCommunicationTracker, propagate, propagateAggregateResultUpdate, pullInto, pullIntoWithTimeline, tupleFromAggregateResult`

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

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

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

      `constructIndex, getChildMailboxes, getPulledContents, getReceivers, issueError, networkStructureChanged, 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.Node

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

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

      `appendParent, batchUpdate, getMailbox, getParents, removeParent`

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

      `constructIndex, getPulledContents, getPulledContents, getReceivers, removeChild`

- - ### Field Detail

    - #### posetComparator

          protected final IPosetComparator posetComparator

      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

    - #### currentGroup

          protected CommunicationGroup currentGroup

      Since:
        1.7

  - ### 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

    - #### isInDRedMode

          public boolean isInDRedMode()

      Description copied from interface: `RederivableNode`
      Returns true if this node actually runs in DRed mode (not necessarily).
      Specified by:
        `isInDRedMode` in interface `RederivableNode`
      Returns:
        true if the node is operating in DRed mode

    - #### 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 `PosetAwareReceiver`

    - #### getPosetMask

          public TupleMask getPosetMask()

      Specified by:
        `getPosetMask` in interface `PosetAwareReceiver`

    - #### getPosetComparator

          public IPosetComparator getPosetComparator()

      Specified by:
        `getPosetComparator` in interface `PosetAwareReceiver`

    - #### 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`

    - #### updateWithPosetInfo

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

      Description copied from interface: `PosetAwareReceiver`
      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:
        `updateWithPosetInfo` in interface `PosetAwareReceiver`
      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,
                             Timestamp timestamp)

      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,
                                       Timestamp timestamp)

      Since:
        2.4

    - #### updateWithDeleteAndRederive

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

      Since:
        2.4

    - #### 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 group)

      Specified by:
        `getAggregateTuple` in class `AbstractColumnAggregatorNode<Domain,​Accumulator,​AggregateResult>`

    - #### getAggregateResult

          public AggregateResult getAggregateResult​(Tuple group)

      Specified by:
        `getAggregateResult` in class `AbstractColumnAggregatorNode<Domain,​Accumulator,​AggregateResult>`

    - #### getAggregateResultTimeline

          public java.util.Map<AggregateResult,​Timeline<Timestamp>> getAggregateResultTimeline​(Tuple key)

      Specified by:
        `getAggregateResultTimeline` in class `AbstractColumnAggregatorNode<Domain,​Accumulator,​AggregateResult>`

    - #### getAggregateTupleTimeline

          public java.util.Map<Tuple,​Timeline<Timestamp>> getAggregateTupleTimeline​(Tuple key)

      Specified by:
        `getAggregateTupleTimeline` in class `AbstractColumnAggregatorNode<Domain,​Accumulator,​AggregateResult>`

    - #### 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

    - #### getCurrentGroup

          public CommunicationGroup getCurrentGroup()

      Specified by:
        `getCurrentGroup` in interface `IGroupable`
      Returns:
        the current group of the mailbox

    - #### setCurrentGroup

          public void setCurrentGroup​(CommunicationGroup currentGroup)

      Description copied from interface: `IGroupable`
      Sets the current group of the mailbox
      Specified by:
        `setCurrentGroup` in interface `IGroupable`