PropagationContext context,
InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
RightTupleMemory rightMemory = memory.getRightTupleMemory();
FastIterator rightIt = getRightIterator( rightMemory );
RightTuple firstRightTuple = getFirstRightTuple(leftTuple, rightMemory, context, rightIt);
// If in memory, remove it, because we'll need to add it anyway if it's not blocked, to ensure iteration order
RightTuple blocker = leftTuple.getBlocker();
if ( blocker == null ) {
if ( leftTuple.getMemory().isStagingMemory() ) {
leftTuple.getMemory().remove( leftTuple );
} else {
memory.getLeftTupleMemory().remove( leftTuple );
}
leftTuple.setMemory( null );
} else {
// check if we changed bucket
if ( rightMemory.isIndexed()&& !rightIt.isFullIterator() ) {
// if newRightTuple is null, we assume there was a bucket change and that bucket is empty
if ( firstRightTuple == null || firstRightTuple.getMemory() != blocker.getMemory() ) {
// we changed bucket, so blocker no longer blocks
blocker.removeBlocked( leftTuple );
leftTuple.setBlocker( null );
leftTuple.setBlockedPrevious( null );
leftTuple.setBlockedNext( null );
blocker = null;
}
}
}
this.constraints.updateFromTuple( memory.getContext(),
workingMemory,
leftTuple );
// if we where not blocked before (or changed buckets), or the previous blocker no longer blocks, then find the next blocker
if ( blocker == null || !this.constraints.isAllowedCachedLeft( memory.getContext(),
blocker.getFactHandle() ) ) {
if ( blocker != null ) {
// remove previous blocker if it exists, as we know it doesn't block any more
blocker.removeBlocked( leftTuple );
leftTuple.setBlocker( null );
leftTuple.setBlockedPrevious( null );
leftTuple.setBlockedNext( null );
}
FastIterator it = memory.getRightTupleMemory().fastIterator();
// find first blocker, because it's a modify, we need to start from the beginning again
for ( RightTuple newBlocker = firstRightTuple; newBlocker != null; newBlocker = (RightTuple) rightIt.next(newBlocker) ) {
if ( this.constraints.isAllowedCachedLeft( memory.getContext(),
newBlocker.getFactHandle() ) ) {