public void doPropagateAssertLeftTuple( PropagationContext context, InternalWorkingMemory workingMemory, LeftTuple leftTuple, LeftTupleSink sink) { sink.assertLeftTuple(leftTuple, context, workingMemory); }
/** Updates the given sink propagating all previously propagated tuples to it */ public void updateSink( final LeftTupleSink sink, final PropagationContext context, final InternalWorkingMemory workingMemory) { final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory(this); Iterator it = memory.getRightTupleMemory().iterator(); // Relies on the fact that any propagated LeftTuples are blocked, but due to lazy blocking // they will only be blocked once. So we can iterate the right memory to find the left tuples to // propagate for (RightTuple rightTuple = (RightTuple) it.next(); rightTuple != null; rightTuple = (RightTuple) it.next()) { LeftTuple leftTuple = rightTuple.getBlocked(); while (leftTuple != null) { sink.assertLeftTuple(sink.createLeftTuple(leftTuple, sink, true), context, workingMemory); leftTuple = leftTuple.getBlockedNext(); } } }
public static void doModifyLeftTuple( InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, InternalWorkingMemory workingMemory, LeftTupleSink sink, ObjectTypeNode.Id leftInputOtnId, BitMask leftInferredMask) { LeftTuple leftTuple = modifyPreviousTuples.peekLeftTuple(); while (leftTuple != null && leftTuple.getLeftTupleSink().getLeftInputOtnId() != null && leftTuple.getLeftTupleSink().getLeftInputOtnId().before(leftInputOtnId)) { modifyPreviousTuples.removeLeftTuple(); // we skipped this node, due to alpha hashing, so retract now ((LeftInputAdapterNode) leftTuple.getLeftTupleSink().getLeftTupleSource()) .retractLeftTuple(leftTuple, context, workingMemory); leftTuple = modifyPreviousTuples.peekLeftTuple(); } if (leftTuple != null && leftTuple.getLeftTupleSink().getLeftInputOtnId() != null && leftTuple.getLeftTupleSink().getLeftInputOtnId().equals(leftInputOtnId)) { modifyPreviousTuples.removeLeftTuple(); leftTuple.reAdd(); if (context.getModificationMask().intersects(leftInferredMask)) { // LeftTuple previously existed, so continue as modify, unless it's currently staged sink.modifyLeftTuple(leftTuple, context, workingMemory); } } else { if (context.getModificationMask().intersects(leftInferredMask)) { // LeftTuple does not exist, so create and continue as assert LeftTuple newLeftTuple = sink.createLeftTuple(factHandle, sink, true); sink.assertLeftTuple(newLeftTuple, context, workingMemory); } } }
public void updateSink( final LeftTupleSink sink, final PropagationContext context, final InternalWorkingMemory workingMemory) { final AccumulateMemory memory = (AccumulateMemory) workingMemory.getNodeMemory(this); final Iterator tupleIter = memory.betaMemory.getLeftTupleMemory().iterator(); for (LeftTuple leftTuple = (LeftTuple) tupleIter.next(); leftTuple != null; leftTuple = (LeftTuple) tupleIter.next()) { AccumulateContext accctx = (AccumulateContext) leftTuple.getObject(); if (accctx.propagated) { // temporarily break the linked list to avoid wrong interactions LeftTuple[] matchings = splitList(leftTuple, accctx, true); sink.assertLeftTuple( sink.createLeftTuple(leftTuple, accctx.result, null, null, sink, true), context, workingMemory); restoreList(leftTuple, matchings); } } }
public void updateSink( final LeftTupleSink sink, final PropagationContext context, final InternalWorkingMemory workingMemory) { LeftTupleIterator it = LeftTupleIterator.iterator(workingMemory, this); for (LeftTuple leftTuple = (LeftTuple) it.next(); leftTuple != null; leftTuple = (LeftTuple) it.next()) { LeftTuple childLeftTuple = leftTuple.getFirstChild(); while (childLeftTuple != null) { RightTuple rightParent = childLeftTuple.getRightParent(); sink.assertLeftTuple( sink.createLeftTuple(leftTuple, rightParent, childLeftTuple, null, sink, true), context, workingMemory); while (childLeftTuple != null && childLeftTuple.getRightParent() == rightParent) { // skip to the next child that has a different right parent childLeftTuple = childLeftTuple.getLeftParentNext(); } } } }