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:
    Node, Supplier
  Direct Known Subclasses:
    ExistenceNode, JoinNode, OuterJoinNode

      public abstract class DualInputNode
      extends StandardNode

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

- - ### Nested Class Summary

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

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `coincidence` true if the primary and secondary slots coincide
    `protected TupleMask` | `complementerSecondaryMask` Optional complementer mask
    `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

      `children`

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

      `nodeId, reteContainer, tag, traceInfos`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DualInputNode(ReteContainer reteContainer, TupleMask complementerSecondaryMask)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `assignTraceInfo(TraceInfo traceInfo)` assigns new traceability info to this node
    `abstract Tuple` | `calibrate(Tuple primary, Tuple secondary)` Simulates the behaviour of the node for calibration purposes only.
    `void` | `connectToIndexers(IterableIndexer primarySlot, Indexer secondarySlot)` Should be called only once, when node is initialized
    `IterableIndexer` | `getPrimarySlot()`
    `Indexer` | `getSecondarySlot()`
    `protected Indexer` | `getSlot(DualInputNode.Side side)` Retrieves the slot corresponding to the specified side.
    `abstract void` | `notifyUpdate(DualInputNode.Side side, Direction direction, Tuple updateElement, Tuple signature, boolean change)` Abstract handler for update event.
    `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(DualInputNode.Side side, Tuple ps, Tuple opposite)` Helper: unifies the a substitution from the specifies side with another substitution from the other side.
    `protected Tuple` | `unify(Tuple left, Tuple right)` Helper: unifies a left and right partial matching.

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

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

      `pullInto`

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

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

- - ### Field Detail

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

  - ### 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. The results are copied into a new collection; this step has a performance penalty, but avoids ConcurrentModificaton Exceptions when loops are present.
      Returns:
        the collection of opposite substitutions if any, or null if none

    - #### unify

          protected Tuple unify(Tuple left,
                                Tuple right)

      Helper: unifies a left and right partial matching.

    - #### unify

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

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

    - #### notifyUpdate

          public abstract void notifyUpdate(DualInputNode.Side side,
                                            Direction direction,
                                            Tuple updateElement,
                                            Tuple signature,
                                            boolean change)

      Abstract handler for update event.
      Parameters:
        `side` - The side on which the event occured.
        `direction` - The direction of the update.
        `updateElement` - The partial matching that is inserted.
        `signature` - Masked signature of updateElement.
        `change` - Indicates whether this is/was the first/last instance of this signature in this slot.

    - #### calibrate

          public abstract Tuple calibrate(Tuple primary,
                                          Tuple secondary)

      Simulates the behaviour 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`