boolean useLeftMemory = true;
RightTupleSets srcRightTuples = am.getBetaMemory().getStagedRightTuples();
// We need to collect which leftTuple where updated, so that we can
// add their result tuple to the real target tuples later
LeftTupleSets tempLeftTuples = new LeftTupleSets();
if ( srcLeftTuples.getDeleteFirst() != null ) {
// use the real target here, as dealing direct with left tuples
doLeftDeletes( accNode, am, wm, srcLeftTuples, trgLeftTuples );
}
if ( srcRightTuples.getDeleteFirst() != null ) {
doRightDeletes( accNode, am, wm, srcRightTuples, tempLeftTuples );
}
if ( srcLeftTuples.getUpdateFirst() != null || srcRightTuples.getUpdateFirst() != null ) {
dpUpdatesReorderLeftMemory( am.getBetaMemory(), wm,
srcRightTuples, srcLeftTuples );
dpUpdatesReorderRightMemory( am.getBetaMemory(), wm,
srcRightTuples, srcLeftTuples );
}
if ( srcLeftTuples.getUpdateFirst() != null ) {
doLeftUpdates( accNode, sink, am, wm, srcLeftTuples, tempLeftTuples );
}
if ( srcRightTuples.getUpdateFirst() != null ) {
doRightUpdates( accNode, sink, am, wm, srcRightTuples, tempLeftTuples );
}
if ( srcRightTuples.getInsertFirst() != null ) {
doRightInserts( accNode, sink, am, wm, srcRightTuples, tempLeftTuples );
}
if ( srcLeftTuples.getInsertFirst() != null ) {
doLeftInserts( accNode, sink, am, wm, srcLeftTuples, tempLeftTuples );
}
Accumulate accumulate = accNode.getAccumulate();
// we do not need collect retracts. RightTuple retracts end up as updates for lefttuples.
// LeftTuple retracts are already on the trgLeftTuples
for ( LeftTuple leftTuple = tempLeftTuples.getInsertFirst(); leftTuple != null; ) {
LeftTuple next = leftTuple.getStagedNext();
evaluateResultConstraints( accNode, sink, accumulate, leftTuple, leftTuple.getPropagationContext(),
wm, am, (AccumulateContext) leftTuple.getObject(), useLeftMemory,
trgLeftTuples, stagedLeftTuples );
leftTuple.clearStaged();
leftTuple = next;
}
for ( LeftTuple leftTuple = tempLeftTuples.getUpdateFirst(); leftTuple != null; ) {
LeftTuple next = leftTuple.getStagedNext();
evaluateResultConstraints( accNode, sink, accumulate, leftTuple, leftTuple.getPropagationContext(),
wm, am, (AccumulateContext) leftTuple.getObject(), useLeftMemory,
trgLeftTuples, stagedLeftTuples );
leftTuple.clearStaged();