Class AbstractConcatNode<LeftTuple_ extends AbstractTuple,RightTuple_ extends AbstractTuple,OutTuple_ extends AbstractTuple>
java.lang.Object
ai.timefold.solver.constraint.streams.bavet.common.AbstractNode
ai.timefold.solver.constraint.streams.bavet.common.AbstractConcatNode<LeftTuple_,RightTuple_,OutTuple_>
- All Implemented Interfaces:
LeftTupleLifecycle<LeftTuple_>,RightTupleLifecycle<RightTuple_>
public abstract class AbstractConcatNode<LeftTuple_ extends AbstractTuple,RightTuple_ extends AbstractTuple,OutTuple_ extends AbstractTuple>
extends AbstractNode
implements LeftTupleLifecycle<LeftTuple_>, RightTupleLifecycle<RightTuple_>
Implements the concat operation. Concat cannot be implemented as a pass-through operation because of two caveats:
- It is possible to have the same
TupleSourcefor both parent streams, in which case the exact same tuple can be inserted twice. Such a tuple should be counted twice downstream, and thus need to be cloned. - Because concat has two parent nodes, it must be a
TupleSource(since all nodes have exactly oneTupleSource, and the source tuple can come from either parent).TupleSourcemust produce new tuples and not reuse them, since if tuples are reused, the stores inside them get corrupted.
AbstractConcatNode works by creating a copy of the source tuple and putting it into
the tuple's store. If the same tuple is inserted twice (i.e. when the left and right parent
have the same TupleSource), it creates another clone.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConcatNode(TupleLifecycle<OutTuple_> nextNodesTupleLifecycle, int leftSourceTupleCloneStoreIndex, int rightSourceTupleCloneStoreIndex, int outputStoreSize) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract OutTuple_getOutTupleFromLeft(LeftTuple_ leftTuple) protected abstract OutTuple_getOutTupleFromRight(RightTuple_ rightTuple) Instead of calling the propagation directly from here, we export the propagation queue and allowBavetConstraintSessionto call it.final voidinsertLeft(LeftTuple_ tuple) final voidinsertRight(RightTuple_ tuple) final voidretractLeft(LeftTuple_ tuple) final voidretractRight(RightTuple_ tuple) final voidupdateLeft(LeftTuple_ tuple) protected abstract voidupdateOutTupleFromLeft(LeftTuple_ leftTuple, OutTuple_ outTuple) protected abstract voidupdateOutTupleFromRight(RightTuple_ rightTuple, OutTuple_ outTuple) final voidupdateRight(RightTuple_ tuple) Methods inherited from class ai.timefold.solver.constraint.streams.bavet.common.AbstractNode
getLayerIndex, setId, setLayerIndex, toString
-
Field Details
-
outputStoreSize
protected final int outputStoreSize
-
-
Constructor Details
-
AbstractConcatNode
protected AbstractConcatNode(TupleLifecycle<OutTuple_> nextNodesTupleLifecycle, int leftSourceTupleCloneStoreIndex, int rightSourceTupleCloneStoreIndex, int outputStoreSize)
-
-
Method Details
-
getOutTupleFromLeft
-
getOutTupleFromRight
-
updateOutTupleFromLeft
-
updateOutTupleFromRight
-
insertLeft
- Specified by:
insertLeftin interfaceLeftTupleLifecycle<LeftTuple_ extends AbstractTuple>
-
updateLeft
- Specified by:
updateLeftin interfaceLeftTupleLifecycle<LeftTuple_ extends AbstractTuple>
-
retractLeft
- Specified by:
retractLeftin interfaceLeftTupleLifecycle<LeftTuple_ extends AbstractTuple>
-
insertRight
- Specified by:
insertRightin interfaceRightTupleLifecycle<LeftTuple_ extends AbstractTuple>
-
updateRight
- Specified by:
updateRightin interfaceRightTupleLifecycle<LeftTuple_ extends AbstractTuple>
-
retractRight
- Specified by:
retractRightin interfaceRightTupleLifecycle<LeftTuple_ extends AbstractTuple>
-
getPropagator
Description copied from class:AbstractNodeInstead of calling the propagation directly from here, we export the propagation queue and allowBavetConstraintSessionto call it. This is done with the idea thatPropagatoronly has two implementations (unlikeAbstractNodewith myriad implementations) and therefore JVM call site optimizations will kick in to make the method dispatch faster.- Specified by:
getPropagatorin classAbstractNode- Returns:
- never null; the
PropagationQueuein use by this node
-