use of org.drools.core.rule.ContextEntry in project drools by kiegroup.
the class PhreakNotNode method doRightInserts.
public void doRightInserts(NotNode notNode, BetaMemory bm, InternalWorkingMemory wm, TupleSets<RightTuple> srcRightTuples, TupleSets<LeftTuple> trgLeftTuples, TupleSets<LeftTuple> stagedLeftTuples) {
TupleMemory ltm = bm.getLeftTupleMemory();
TupleMemory rtm = bm.getRightTupleMemory();
ContextEntry[] contextEntry = bm.getContext();
BetaConstraints constraints = notNode.getRawConstraints();
// this must be processed here, rather than initial insert, as we need to link the blocker
unlinkNotNodeOnRightInsert(notNode, bm, wm);
for (RightTuple rightTuple = srcRightTuples.getInsertFirst(); rightTuple != null; ) {
RightTuple next = rightTuple.getStagedNext();
rtm.add(rightTuple);
if (ltm != null && ltm.size() > 0) {
FastIterator it = notNode.getLeftIterator(ltm);
constraints.updateFromFactHandle(contextEntry, wm, rightTuple.getFactHandleForEvaluation());
for (LeftTuple leftTuple = notNode.getFirstLeftTuple(rightTuple, ltm, it); leftTuple != null; ) {
// preserve next now, in case we remove this leftTuple
LeftTuple temp = (LeftTuple) it.next(leftTuple);
if (leftTuple.getStagedType() == LeftTuple.UPDATE) {
// ignore, as it will get processed via left iteration. Children cannot be processed twice
leftTuple = temp;
continue;
}
// we know that only unblocked LeftTuples are still in the memory
if (constraints.isAllowedCachedRight(contextEntry, leftTuple)) {
leftTuple.setBlocker(rightTuple);
rightTuple.addBlocked(leftTuple);
// this is now blocked so remove from memory
ltm.remove(leftTuple);
// subclasses like ForallNotNode might override this propagation
// ** @TODO (mdp) need to not break forall
LeftTuple childLeftTuple = leftTuple.getFirstChild();
if (childLeftTuple != null) {
// NotNode only has one child
childLeftTuple.setPropagationContext(rightTuple.getPropagationContext());
RuleNetworkEvaluator.unlinkAndDeleteChildLeftTuple(childLeftTuple, trgLeftTuples, stagedLeftTuples);
}
}
leftTuple = temp;
}
}
rightTuple.clearStaged();
rightTuple = next;
}
constraints.resetFactHandle(contextEntry);
}
Aggregations