LeftTupleSets trgLeftTuples) {
Accumulate accumulate = accNode.getAccumulate();
BetaMemory bm = am.getBetaMemory();
LeftTupleMemory ltm = bm.getLeftTupleMemory();
RightTupleMemory rtm = bm.getRightTupleMemory();
ContextEntry[] contextEntry = bm.getContext();
BetaConstraints constraints = accNode.getRawConstraints();
for (LeftTuple leftTuple = srcLeftTuples.getInsertFirst(); leftTuple != null; ) {
LeftTuple next = leftTuple.getStagedNext();
boolean useLeftMemory = RuleNetworkEvaluator.useLeftMemory(accNode, leftTuple);
if (useLeftMemory) {
ltm.add(leftTuple);
}
PropagationContext context = leftTuple.getPropagationContext();
AccumulateContext accresult = new AccumulateContext();
leftTuple.setObject(accresult);
accresult.context = accumulate.createContext();
accumulate.init(am.workingMemoryContext,
accresult.context,
leftTuple,
wm);
constraints.updateFromTuple(contextEntry,
wm,
leftTuple);
FastIterator rightIt = accNode.getRightIterator(rtm);
for (RightTuple rightTuple = accNode.getFirstRightTuple(leftTuple,
rtm,
null,
rightIt); rightTuple != null; ) {
RightTuple nextRightTuple = (RightTuple) rightIt.next(rightTuple);
InternalFactHandle handle = rightTuple.getFactHandle();
if (constraints.isAllowedCachedLeft(contextEntry,
handle)) {
// add a match
addMatch(accNode,
accumulate,
leftTuple,
rightTuple,
null,
null,
wm,
am,
accresult,
useLeftMemory);
if (!useLeftMemory && accNode.isRightInputIsRiaNode()) {
// RIAN with no left memory must have their right tuples removed
rtm.remove(rightTuple);
}
}
rightTuple = nextRightTuple;
}