BetaConstraints constraints = existsNode.getRawConstraints();
FastIterator leftIt = existsNode.getLeftIterator( ltm );
FastIterator rightIt = existsNode.getRightIterator( rtm );
for ( RightTuple rightTuple = srcRightTuples.getUpdateFirst(); rightTuple != null; ) {
RightTuple next = rightTuple.getStagedNext();
PropagationContext context = rightTuple.getPropagationContext();
LeftTuple firstLeftTuple = existsNode.getFirstLeftTuple( rightTuple, ltm, context, leftIt );
LeftTuple firstBlocked = rightTuple.getBlocked();
// we now have reference to the first Blocked, so null it in the rightTuple itself, so we can rebuild
rightTuple.nullBlocked();
// first process non-blocked tuples, as we know only those ones are in the left memory.
for ( LeftTuple leftTuple = firstLeftTuple; leftTuple != null; ) {
// preserve next now, in case we remove this leftTuple
LeftTuple temp = (LeftTuple) leftIt.next( leftTuple );
// 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
trgLeftTuples.addInsert( sink.createLeftTuple( leftTuple,
sink,
tupleMemory ) );
}
leftTuple = temp;
}
if ( firstBlocked != null ) {
boolean useComparisonIndex = rtm.getIndexType().isComparison();
// now process existing blocks, we only process existing and not new from above loop
RightTuple rootBlocker = useComparisonIndex ? null : (RightTuple) rightIt.next(rightTuple);
RightTupleList list = rightTuple.getMemory();
// we must do this after we have the next in memory
// We add to the end to give an opportunity to re-match if in same bucket