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 classDualInputNode.NetworkStructureChangeSensitiveLogicstatic classDualInputNode.Side
-
Field Summary
Fields Modifier and Type Field Description protected booleancoincidencetrue if the primary and secondary slots coincideprotected TupleMaskcomplementerSecondaryMaskOptional complementer maskprotected java.util.Map<Indexer,java.lang.Boolean>indexerGroupCacheThis map caches the result of a CommunicationTracker.areInSameGroup(indexer, this) call.protected DualInputNode.NetworkStructureChangeSensitiveLogiclogicprotected IterableIndexerprimarySlotHolds the primary input slot of this node.protected IndexersecondarySlotHolds 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 voidassignTraceInfo(TraceInfo traceInfo)assigns new traceability info to this nodeabstract Tuplecalibrate(Tuple primary, Tuple secondary)Simulates the behavior of the node for calibration purposes only.voidconnectToIndexers(IterableIndexer primarySlot, Indexer secondarySlot)Should be called only once, when node is initialized.protected DualInputNode.NetworkStructureChangeSensitiveLogiccreateLogic()protected abstract DualInputNode.NetworkStructureChangeSensitiveLogiccreateTimelessLogic()protected abstract DualInputNode.NetworkStructureChangeSensitiveLogiccreateTimelyLogic()IterableIndexergetPrimarySlot()IndexergetSecondarySlot()protected IndexergetSlot(DualInputNode.Side side)Retrieves the slot corresponding to the specified side.protected java.util.Map<Tuple,Timeline<Timestamp>>getTimeline(Tuple signature, Indexer indexer)voidnetworkStructureChanged()At the time of the invocation, the dependency graph has already been updated.voidpullInto(java.util.Collection<Tuple> collector, boolean flush)Pulls the contents of this object in this particular moment into a target collection.voidpullIntoWithTimeline(java.util.Map<Tuple,Timeline<Timestamp>> collector, boolean flush)protected voidrefreshIndexerGroupCache()protected java.util.Collection<Tuple>retrieveOpposites(DualInputNode.Side side, Tuple signature)Helper: retrieves all stored substitutions from the opposite side memory.voidsetComplementerSecondaryMask(TupleMask complementerSecondaryMask)protected Tupleunify(Tuple left, Tuple right)Helper: unifies a left and right partial matching.protected Tupleunify(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:SupplierPulls the contents of this object in this particular moment into a target collection.
-
pullIntoWithTimeline
public void pullIntoWithTimeline(java.util.Map<Tuple,Timeline<Timestamp>> collector, boolean flush)
- Specified by:
pullIntoWithTimelinein interfaceSupplier
-
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:Nodeassigns new traceability info to this node- Specified by:
assignTraceInfoin interfaceNode- Overrides:
assignTraceInfoin classBaseNode
-
networkStructureChanged
public void networkStructureChanged()
Description copied from interface:NetworkStructureChangeSensitiveNodeAt the time of the invocation, the dependency graph has already been updated.- Specified by:
networkStructureChangedin interfaceNetworkStructureChangeSensitiveNode- Overrides:
networkStructureChangedin classStandardNode
-
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
-
-