org.eclipse.viatra.query.runtime.rete.eval

## Class OutputCachingEvaluatorNode

- 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.eval.AbstractEvaluatorNode
        - - org.eclipse.viatra.query.runtime.rete.eval.OutputCachingEvaluatorNode

- All Implemented Interfaces:
    Clearable, IEvaluatorNode, org.eclipse.viatra.query.runtime.rete.network.communication.timely.ResumableNode, IGroupable, NetworkStructureChangeSensitiveNode, Node, Receiver, Supplier, Tunnel

      public class OutputCachingEvaluatorNode
      extends AbstractEvaluatorNode
      implements Clearable, org.eclipse.viatra.query.runtime.rete.network.communication.timely.ResumableNode

  An evaluator node that caches the evaluation result. This node is also capable of caching the timestamps associated with the result tuples if it is used in recursive differential dataflow evaluation.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `OutputCachingEvaluatorNode.NetworkStructureChangeSensitiveLogic`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CommunicationGroup` | `group`
    `protected OutputCachingEvaluatorNode.NetworkStructureChangeSensitiveLogic` | `logic`
    `protected TimelyMemory<Timestamp>` | `memory` Maps input tuples to timestamps.
    `protected java.util.Map<Tuple,java.lang.Iterable<Tuple>>` | `outputCache`

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.rete.eval.AbstractEvaluatorNode

      `core`

    - ### 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 and Description
    `OutputCachingEvaluatorNode(ReteContainer reteContainer, EvaluatorCore core)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clear all partial matchings stored in memory
    `protected OutputCachingEvaluatorNode.NetworkStructureChangeSensitiveLogic` | `createLogic()`
    `CommunicationGroup` | `getCurrentGroup()`
    `Timestamp` | `getResumableTimestamp()` Returns the smallest timestamp where lazy folding shall be resumed, or null if there is no more folding to do in this resumable.
    `void` | `networkStructureChanged()` At the time of the invocation, the dependency graph has already been updated.
    `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)`
    `void` | `resumeAt(Timestamp timestamp)` When called, the folding of the state shall be resumed at the given timestamp.
    `void` | `setCurrentGroup(CommunicationGroup group)` Sets the current group of the mailbox
    `void` | `update(Direction direction, Tuple input, Timestamp timestamp)` Updates the receiver with a newly found or lost partial matching.

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.rete.eval.AbstractEvaluatorNode

      `getReteContainer, prettyPrintTraceInfoPatternList, propagateIterableUpdate`

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

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

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

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

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

      `appendChild, constructIndex, getPulledContents, getPulledContents, getReceivers, removeChild`

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

      `batchUpdate`

- - ### Field Detail

    - #### logic

          protected OutputCachingEvaluatorNode.NetworkStructureChangeSensitiveLogic logic

      Since:
        2.3

    - #### outputCache

          protected java.util.Map<Tuple,java.lang.Iterable<Tuple>> outputCache

      Since:
        2.4

    - #### memory

          protected TimelyMemory<Timestamp> memory

      Maps input tuples to timestamps. It is wrong to map evaluation result to timestamps because the different input tuples may yield the same evaluation result. This field is null as long as this node is in a non-recursive group.
      Since:
        2.4

    - #### group

          protected CommunicationGroup group

      Since:
        2.4

  - ### Constructor Detail

    - #### OutputCachingEvaluatorNode

          public OutputCachingEvaluatorNode(ReteContainer reteContainer,
                                            EvaluatorCore core)

      Since:
        1.5

  - ### Method Detail

    - #### getCurrentGroup

          public CommunicationGroup getCurrentGroup()

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

    - #### setCurrentGroup

          public void setCurrentGroup(CommunicationGroup group)

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

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

    - #### clear

          public void clear()

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

    - #### createLogic

          protected OutputCachingEvaluatorNode.NetworkStructureChangeSensitiveLogic createLogic()

      Since:
        2.3

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

    - #### update

          public void update(Direction direction,
                             Tuple input,
                             Timestamp timestamp)

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

    - #### getResumableTimestamp

          public Timestamp getResumableTimestamp()

      Description copied from interface: `org.eclipse.viatra.query.runtime.rete.network.communication.timely.ResumableNode`
      Returns the smallest timestamp where lazy folding shall be resumed, or null if there is no more folding to do in this resumable.
      Specified by:
        `getResumableTimestamp` in interface `org.eclipse.viatra.query.runtime.rete.network.communication.timely.ResumableNode`
      Since:
        2.4

    - #### resumeAt

          public void resumeAt(Timestamp timestamp)

      Description copied from interface: `org.eclipse.viatra.query.runtime.rete.network.communication.timely.ResumableNode`
      When called, the folding of the state shall be resumed at the given timestamp. The resumable is expected to do a folding step at the given timestamp only. Afterwards, folding shall be interrupted, even if there is more folding to do towards higher timestamps.
      Specified by:
        `resumeAt` in interface `org.eclipse.viatra.query.runtime.rete.network.communication.timely.ResumableNode`
      Since:
        2.4