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

## Class IndexerBasedAggregatorNode

- 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.aggregation.IndexerBasedAggregatorNode

- All Implemented Interfaces:
    IAggregatorNode, NetworkStructureChangeSensitiveNode, Node, Supplier
  Direct Known Subclasses:
    CountNode

      public abstract class IndexerBasedAggregatorNode
      extends StandardNode
      implements IAggregatorNode

  A special node depending on a projection indexer to aggregate tuple groups with the same projection. Only propagates the aggregates of non-empty groups. Use the outer indexers to circumvent.

  This node cannot be used in recursive differential dataflow evaluation.

  Since:
    1.4

- - ### Field Summary

    - ### 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 and Description
    `IndexerBasedAggregatorNode(ReteContainer reteContainer)` MUST call initializeWith() afterwards!

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Tuple` | `aggregateAndPack(Tuple signature, java.util.Collection<Tuple> group)`
    `abstract java.lang.Object` | `aggregateGroup(Tuple signature, java.util.Collection<Tuple> group)` Aggregates (reduces) a group of tuples.
    `java.lang.Object` | `aggregateGroupAfterUpdate(Tuple signature, java.util.Collection<Tuple> currentGroup, java.lang.Object oldAggregate, Direction direction, Tuple updateElement, boolean change)` Aggregates (reduces) a group of tuples, having access to the previous aggregated value (before the update) and the update definition.
    `protected void` | `aggregateUpdate(Direction direction, Tuple updateElement, Tuple signature, boolean change)`
    `void` | `assignTraceInfo(TraceInfo traceInfo)` assigns new traceability info to this node
    `Indexer` | `getAggregatorOuterIdentityIndexer(int resultPositionInSignature)`
    `Indexer` | `getAggregatorOuterIndexer()`
    `void` | `initializeWith(ProjectionIndexer projection)`
    `void` | `networkStructureChanged()` At the time of the invocation, the dependency graph has already been updated.
    `protected Tuple` | `packResult(Tuple signature, java.lang.Object result)`
    `void` | `pullInto(java.util.Collection<Tuple> collector, boolean flush)` Pulls the contents of this object in this particular moment into a target collection.
    `void` | `pullIntoWithTimeline(java.util.Map<Tuple,Timeline<Timestamp>> collector, boolean flush)`

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

      `appendChild, constructIndex, getChildMailboxes, 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.Supplier

      `getPulledContents`

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

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

- - ### Constructor Detail

    - #### IndexerBasedAggregatorNode

          public IndexerBasedAggregatorNode(ReteContainer reteContainer)

      MUST call initializeWith() afterwards!

  - ### Method Detail

    - #### networkStructureChanged

          public void networkStructureChanged()

      Description copied from interface: `NetworkStructureChangeSensitiveNode`
      At the time of the invocation, the dependency graph has already been updated.
      Specified by:
        `networkStructureChanged` in interface `NetworkStructureChangeSensitiveNode`
      Overrides:
        `networkStructureChanged` in class `StandardNode`

    - #### initializeWith

          public void initializeWith(ProjectionIndexer projection)

      Parameters:
        `projection` - the projection indexer whose tuple groups should be aggregated

    - #### aggregateGroup

          public abstract java.lang.Object aggregateGroup(Tuple signature,
                                                          java.util.Collection<Tuple> group)

      Aggregates (reduces) a group of tuples. The group can be null.

    - #### aggregateGroupAfterUpdate

          public java.lang.Object aggregateGroupAfterUpdate(Tuple signature,
                                                            java.util.Collection<Tuple> currentGroup,
                                                            java.lang.Object oldAggregate,
                                                            Direction direction,
                                                            Tuple updateElement,
                                                            boolean change)

      Aggregates (reduces) a group of tuples, having access to the previous aggregated value (before the update) and the update definition. Defaults to aggregateGroup(). Override to increase performance.
      Since:
        2.4

    - #### aggregateAndPack

          protected Tuple aggregateAndPack(Tuple signature,
                                           java.util.Collection<Tuple> group)

    - #### getAggregatorOuterIndexer

          public Indexer getAggregatorOuterIndexer()

      Specified by:
        `getAggregatorOuterIndexer` in interface `IAggregatorNode`

    - #### getAggregatorOuterIdentityIndexer

          public Indexer getAggregatorOuterIdentityIndexer(int resultPositionInSignature)

      Specified by:
        `getAggregatorOuterIdentityIndexer` in interface `IAggregatorNode`

    - #### pullInto

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

      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`
        `flush` - if true, flushing of messages is allowed during the pull, otherwise flushing is not allowed

    - #### pullIntoWithTimeline

          public void pullIntoWithTimeline(java.util.Map<Tuple,Timeline<Timestamp>> collector,
                                           boolean flush)

      Specified by:
        `pullIntoWithTimeline` in interface `Supplier`

    - #### packResult

          protected Tuple packResult(Tuple signature,
                                     java.lang.Object result)

    - #### aggregateUpdate

          protected void aggregateUpdate(Direction direction,
                                         Tuple updateElement,
                                         Tuple signature,
                                         boolean change)

      Since:
        2.4

    - #### assignTraceInfo

          public void assignTraceInfo(TraceInfo traceInfo)

      Description copied from interface: `Node`
      assigns new traceability info to this node
      Specified by:
        `assignTraceInfo` in interface `Node`
      Overrides:
        `assignTraceInfo` in class `BaseNode`