use of org.drools.core.reteoo.RightTuple in project drools by kiegroup.
the class RuleNetworkEvaluator method doUpdatesExistentialReorderLeftMemory.
public static void doUpdatesExistentialReorderLeftMemory(BetaMemory bm, TupleSets<LeftTuple> srcLeftTuples) {
TupleMemory ltm = bm.getLeftTupleMemory();
// sides must first be re-ordered, to ensure iteration integrity
for (LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; leftTuple = leftTuple.getStagedNext()) {
if (leftTuple.getMemory() != null) {
ltm.remove(leftTuple);
}
}
for (LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; leftTuple = leftTuple.getStagedNext()) {
RightTuple blocker = leftTuple.getBlocker();
if (blocker == null) {
ltm.add(leftTuple);
for (LeftTuple childLeftTuple = leftTuple.getFirstChild(); childLeftTuple != null; ) {
LeftTuple childNext = childLeftTuple.getHandleNext();
childLeftTuple.reAddRight();
childLeftTuple = childNext;
}
} else if (blocker.getStagedType() != LeftTuple.NONE) {
// it's blocker is also being updated, so remove to force it to start from the beginning
blocker.removeBlocked(leftTuple);
}
}
}
use of org.drools.core.reteoo.RightTuple in project drools by kiegroup.
the class RightMemory method getRightTuples.
public List<RightTuple> getRightTuples(Object... objects) {
BetaNode node = scenario.getBetaNode();
BetaMemory bm = scenario.getBm();
TupleMemory rtm = bm.getRightTupleMemory();
InternalWorkingMemory wm = scenario.getWorkingMemory();
if (objects == null) {
objects = new Object[0];
}
List<RightTuple> rightTuples = new ArrayList<RightTuple>();
for (Object object : objects) {
InternalFactHandle fh = (InternalFactHandle) wm.insert(object);
// node.createLeftTuple( fh, node, true );
RightTuple expectedRightTuple = new RightTupleImpl(fh, node);
expectedRightTuple.setPropagationContext(new PhreakPropagationContext());
rightTuples.add(expectedRightTuple);
}
scenario.setTestRightMemory(true);
return rightTuples;
}
use of org.drools.core.reteoo.RightTuple in project drools by kiegroup.
the class RightBuilder method delete.
public RightBuilder delete(Object... objects) {
for (Object object : objects) {
InternalFactHandle fh = (InternalFactHandle) wm.insert(object);
RightTuple rightTuple = fh.getFirstRightTuple();
rightTuple.setPropagationContext(new PhreakPropagationContext());
rightTuples.addDelete(rightTuple);
}
return this;
}
use of org.drools.core.reteoo.RightTuple in project drools by kiegroup.
the class RightBuilder method insert.
public RightBuilder insert(Object... objects) {
for (Object object : objects) {
InternalFactHandle fh = (InternalFactHandle) wm.insert(object);
RightTuple rightTuple = new RightTupleImpl(fh, sink);
rightTuple.setPropagationContext(new PhreakPropagationContext());
rightTuples.addInsert(rightTuple);
}
return this;
}
use of org.drools.core.reteoo.RightTuple in project drools by kiegroup.
the class Scenario method equalsRightMemory.
public void equalsRightMemory(List<RightTuple> rightTuples) {
TupleMemory rtm = bm.getRightTupleMemory();
int length = 0;
for (RightTuple expectedRightTuple : rightTuples) {
FastIterator it = betaNode.getRightIterator(rtm);
Tuple actualRightTuple = null;
for (actualRightTuple = BetaNode.getFirstTuple(rtm, it); actualRightTuple != null; actualRightTuple = (RightTuple) it.next(actualRightTuple)) {
if (expectedRightTuple.equals(actualRightTuple)) {
length++;
break;
}
}
if (actualRightTuple == null) {
fail("Could not find RightTuple: " + expectedRightTuple);
}
}
if (rightTuples.size() != rtm.size()) {
fail("RightTuple memory size did not match: " + length);
}
}
Aggregations