use of org.drools.core.reteoo.AccumulateNode.BaseAccumulation in project drools by kiegroup.
the class PhreakAccumulateNode method doLeftUpdates.
private void doLeftUpdates(AccumulateNode accNode, AccumulateMemory am, ReteEvaluator reteEvaluator, TupleSets<LeftTuple> srcLeftTuples, TupleSets<LeftTuple> trgLeftTuples) {
BetaMemory bm = am.getBetaMemory();
TupleMemory rtm = bm.getRightTupleMemory();
Accumulate accumulate = accNode.getAccumulate();
ContextEntry[] contextEntry = bm.getContext();
BetaConstraints constraints = accNode.getRawConstraints();
for (LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; ) {
LeftTuple next = leftTuple.getStagedNext();
BaseAccumulation accctx = (BaseAccumulation) leftTuple.getContextObject();
if (accNode.isRightInputIsRiaNode()) {
// This is a subnetwork, do not process further. As all matches will processed
// by the right updates. This is to avoid double iteration (first right side iteration
// then left side iteration) or for the join to find matching tuple chains, which it previously
// did via subsumption checking.
leftTuple.clearStaged();
trgLeftTuples.addUpdate(leftTuple);
leftTuple = next;
continue;
}
constraints.updateFromTuple(contextEntry, reteEvaluator, leftTuple);
FastIterator rightIt = accNode.getRightIterator(rtm);
RightTuple rightTuple = accNode.getFirstRightTuple(leftTuple, rtm, rightIt);
LeftTuple childLeftTuple = leftTuple.getFirstChild();
// if rightTuple is null, we assume there was a bucket change and that bucket is empty
if (childLeftTuple != null && rtm.isIndexed() && !rightIt.isFullIterator() && (rightTuple == null || (rightTuple.getMemory() != childLeftTuple.getRightParent().getMemory()))) {
// our index has changed, so delete all the previous matchings
removePreviousMatchesForLeftTuple(accumulate, leftTuple, reteEvaluator, am, accctx, true);
// null so the next check will attempt matches for new bucket
childLeftTuple = null;
}
// we can't do anything if RightTupleMemory is empty
if (rightTuple != null) {
doLeftUpdatesProcessChildren(accNode, am, reteEvaluator, bm, accumulate, constraints, rightIt, leftTuple, accctx, rightTuple, childLeftTuple);
}
leftTuple.clearStaged();
trgLeftTuples.addUpdate(leftTuple);
leftTuple = next;
}
constraints.resetTuple(contextEntry);
}
use of org.drools.core.reteoo.AccumulateNode.BaseAccumulation in project drools by kiegroup.
the class PhreakAccumulateNode method doLeftInserts.
private void doLeftInserts(AccumulateNode accNode, AccumulateMemory am, ReteEvaluator reteEvaluator, TupleSets<LeftTuple> srcLeftTuples, TupleSets<LeftTuple> trgLeftTuples) {
Accumulate accumulate = accNode.getAccumulate();
BetaMemory bm = am.getBetaMemory();
TupleMemory ltm = bm.getLeftTupleMemory();
TupleMemory rtm = bm.getRightTupleMemory();
ContextEntry[] contextEntry = bm.getContext();
BetaConstraints constraints = accNode.getRawConstraints();
boolean leftTupleMemoryEnabled = accNode.isLeftTupleMemoryEnabled();
for (LeftTuple leftTuple = srcLeftTuples.getInsertFirst(); leftTuple != null; ) {
LeftTuple next = leftTuple.getStagedNext();
boolean useLeftMemory = leftTupleMemoryEnabled || RuleNetworkEvaluator.useLeftMemory(accNode, leftTuple);
if (useLeftMemory) {
ltm.add(leftTuple);
}
BaseAccumulation accresult = initAccumulationContext(am, reteEvaluator, accumulate, leftTuple);
if (accNode.isRightInputIsRiaNode()) {
// This is a subnetwork, do not process further. As all matches will processed
// by the right insert. This is to avoid double iteration (first right side iteration
// then left side iteration) or for the join to find matching tuple chains, which it previously
// did via subsumption checking.
leftTuple.clearStaged();
trgLeftTuples.addInsert(leftTuple);
leftTuple = next;
continue;
}
constraints.updateFromTuple(contextEntry, reteEvaluator, leftTuple);
FastIterator rightIt = accNode.getRightIterator(rtm);
for (RightTuple rightTuple = accNode.getFirstRightTuple(leftTuple, rtm, rightIt); rightTuple != null; ) {
RightTuple nextRightTuple = (RightTuple) rightIt.next(rightTuple);
if (constraints.isAllowedCachedLeft(contextEntry, rightTuple.getFactHandleForEvaluation())) {
// add a match
addMatch(accNode, accumulate, leftTuple, rightTuple, null, null, reteEvaluator, am, accresult, useLeftMemory, true);
}
rightTuple = nextRightTuple;
}
leftTuple.clearStaged();
trgLeftTuples.addInsert(leftTuple);
constraints.resetTuple(contextEntry);
leftTuple = next;
}
constraints.resetTuple(contextEntry);
}
Aggregations