Package org.eclipse.viatra.query.runtime.rete.index

## Class DualInputNode

- 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.index.DualInputNode

- All Implemented Interfaces:
    `NetworkStructureChangeSensitiveNode`, `Node`, `Supplier`
  Direct Known Subclasses:
    `ExistenceNode`, `JoinNode`

      public abstract class DualInputNode
      extends StandardNode
      implements NetworkStructureChangeSensitiveNode

  Abstract superclass for nodes with two inputs that are matched against each other.

- - ### Nested Class Summary

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

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected boolean` | `coincidence` | true if the primary and secondary slots coincide
    `protected TupleMask` | `complementerSecondaryMask` | Optional complementer mask
    `protected java.util.Map<Indexer,​java.lang.Boolean>` | `indexerGroupCache` | This map caches the result of a CommunicationTracker.areInSameGroup(indexer, this) call.
    `protected DualInputNode.NetworkStructureChangeSensitiveLogic` | `logic` |
    `protected IterableIndexer` | `primarySlot` | Holds the primary input slot of this node.
    `protected Indexer` | `secondarySlot` | Holds the secondary input slot of this node.

    - ### 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
    --- | ---
    `DualInputNode​(ReteContainer reteContainer, TupleMask complementerSecondaryMask)` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `assignTraceInfo​(TraceInfo traceInfo)` | assigns new traceability info to this node
    `abstract Tuple` | `calibrate​(Tuple primary, Tuple secondary)` | Simulates the behavior of the node for calibration purposes only.
    `void` | `connectToIndexers​(IterableIndexer primarySlot, Indexer secondarySlot)` | Should be called only once, when node is initialized.
    `protected DualInputNode.NetworkStructureChangeSensitiveLogic` | `createLogic()` |
    `protected abstract DualInputNode.NetworkStructureChangeSensitiveLogic` | `createTimelessLogic()` |
    `protected abstract DualInputNode.NetworkStructureChangeSensitiveLogic` | `createTimelyLogic()` |
    `IterableIndexer` | `getPrimarySlot()` |
    `Indexer` | `getSecondarySlot()` |
    `protected Indexer` | `getSlot​(DualInputNode.Side side)` | Retrieves the slot corresponding to the specified side.
    `protected java.util.Map<Tuple,​Timeline<Timestamp>>` | `getTimeline​(Tuple signature, Indexer indexer)` |
    `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)` |
    `protected void` | `refreshIndexerGroupCache()` |
    `protected java.util.Collection<Tuple>` | `retrieveOpposites​(DualInputNode.Side side, Tuple signature)` | Helper: retrieves all stored substitutions from the opposite side memory.
    `void` | `setComplementerSecondaryMask​(TupleMask complementerSecondaryMask)` |
    `protected Tuple` | `unify​(Tuple left, Tuple right)` | Helper: unifies a left and right partial matching.
    `protected Tuple` | `unify​(DualInputNode.Side side, Tuple ps, Tuple opposite)` | Helper: unifies a substitution from the specified side with another substitution from the other side.

    - ### 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, getCommunicationTracker, getContainer, getNodeId, getTag, getTraceInfos, setTag`

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

      `getPulledContents`

- - ### Field Detail

    - #### logic

          protected DualInputNode.NetworkStructureChangeSensitiveLogic logic

      Since:
        2.3

    - #### primarySlot

          protected IterableIndexer primarySlot

      Holds the primary input slot of this node.

    - #### secondarySlot

          protected Indexer secondarySlot

      Holds the secondary input slot of this node.

    - #### complementerSecondaryMask

          protected TupleMask complementerSecondaryMask

      Optional complementer mask

    - #### coincidence

          protected boolean coincidence

      true if the primary and secondary slots coincide

    - #### indexerGroupCache

          protected java.util.Map<Indexer,​java.lang.Boolean> indexerGroupCache

      This map caches the result of a CommunicationTracker.areInSameGroup(indexer, this) call. It does that for both the primary and secondary slots. This way we can avoid the lookup in the getWithTimestamp call for each tuple. The cache needs to be maintained when the network structure changes.
      Since:
        2.3

  - ### Constructor Detail

    - #### DualInputNode

          public DualInputNode​(ReteContainer reteContainer,
                               TupleMask complementerSecondaryMask)

      Parameters:
        `reteContainer` -

  - ### Method Detail

    - #### getPrimarySlot

          public IterableIndexer getPrimarySlot()

    - #### getSecondarySlot

          public Indexer getSecondarySlot()

    - #### connectToIndexers

          public void connectToIndexers​(IterableIndexer primarySlot,
                                        Indexer secondarySlot)

      Should be called only once, when node is initialized.

    - #### retrieveOpposites

          protected java.util.Collection<Tuple> retrieveOpposites​(DualInputNode.Side side,
                                                                  Tuple signature)

      Helper: retrieves all stored substitutions from the opposite side memory.
      Returns:
        the collection of opposite substitutions if any, or null if none

    - #### createLogic

          protected DualInputNode.NetworkStructureChangeSensitiveLogic createLogic()

      Since:
        2.3

    - #### unify

          protected Tuple unify​(Tuple left,
                                Tuple right)

      Helper: unifies a left and right partial matching.

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

    - #### unify

          protected Tuple unify​(DualInputNode.Side side,
                                Tuple ps,
                                Tuple opposite)

      Helper: unifies a substitution from the specified side with another substitution from the other side.

    - #### calibrate

          public abstract Tuple calibrate​(Tuple primary,
                                          Tuple secondary)

      Simulates the behavior of the node for calibration purposes only.

    - #### setComplementerSecondaryMask

          public void setComplementerSecondaryMask​(TupleMask complementerSecondaryMask)

      Parameters:
        `complementerSecondaryMask` - the complementerSecondaryMask to set

    - #### getSlot

          protected Indexer getSlot​(DualInputNode.Side side)

      Retrieves the slot corresponding to the specified side.

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

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

    - #### createTimelyLogic

          protected abstract DualInputNode.NetworkStructureChangeSensitiveLogic createTimelyLogic()

      Since:
        2.3

    - #### createTimelessLogic

          protected abstract DualInputNode.NetworkStructureChangeSensitiveLogic createTimelessLogic()

      Since:
        2.3

    - #### refreshIndexerGroupCache

          protected void refreshIndexerGroupCache()

      Since:
        2.3

    - #### getTimeline

          protected java.util.Map<Tuple,​Timeline<Timestamp>> getTimeline​(Tuple signature,
                                                                               Indexer indexer)

      Since:
        2.4