use of org.drools.core.reteoo.LeftTuple in project drools by kiegroup.
the class PhreakTimerNode method doLeftInserts.
public void doLeftInserts(TimerNode timerNode, TimerNodeMemory tm, PathMemory pmem, SegmentMemory smem, LeftTupleSink sink, InternalAgenda agenda, TupleSets<LeftTuple> srcLeftTuples, TupleSets<LeftTuple> trgLeftTuples) {
Timer timer = timerNode.getTimer();
TimerService timerService = agenda.getWorkingMemory().getTimerService();
long timestamp = timerService.getCurrentTime();
String[] calendarNames = timerNode.getCalendarNames();
Calendars calendars = agenda.getWorkingMemory().getCalendars();
for (LeftTuple leftTuple = srcLeftTuples.getInsertFirst(); leftTuple != null; ) {
LeftTuple next = leftTuple.getStagedNext();
scheduleLeftTuple(timerNode, tm, pmem, smem, sink, agenda, timer, timerService, timestamp, calendarNames, calendars, leftTuple, trgLeftTuples, null);
leftTuple.clearStaged();
leftTuple = next;
}
}
use of org.drools.core.reteoo.LeftTuple in project drools by kiegroup.
the class PhreakTimerNode method doPropagateChildLeftTuple.
private static LeftTuple doPropagateChildLeftTuple(LeftTupleSink sink, TupleSets<LeftTuple> trgLeftTuples, TupleSets<LeftTuple> stagedLeftTuples, LeftTuple leftTuple) {
LeftTuple childLeftTuple = leftTuple.getFirstChild();
if (childLeftTuple == null) {
childLeftTuple = sink.createLeftTuple(leftTuple, sink, leftTuple.getPropagationContext(), true);
trgLeftTuples.addInsert(childLeftTuple);
if (log.isTraceEnabled()) {
log.trace("Timer Insert {}", childLeftTuple);
}
} else if (childLeftTuple.getContextObject() == Boolean.TRUE) {
// This childLeftTuple has been created in this doNode loop, just skip it
childLeftTuple.setContextObject(null);
} else {
normalizeStagedTuples(stagedLeftTuples, childLeftTuple);
trgLeftTuples.addUpdate(childLeftTuple);
if (log.isTraceEnabled()) {
log.trace("Timer Update {}", childLeftTuple);
}
}
return childLeftTuple;
}
use of org.drools.core.reteoo.LeftTuple in project drools by kiegroup.
the class RuleNetworkEvaluator method doUpdatesReorderLeftMemory.
public static void doUpdatesReorderLeftMemory(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()) {
ltm.remove(leftTuple);
}
for (LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; leftTuple = leftTuple.getStagedNext()) {
ltm.add(leftTuple);
for (LeftTuple childLeftTuple = leftTuple.getFirstChild(); childLeftTuple != null; ) {
LeftTuple childNext = childLeftTuple.getHandleNext();
childLeftTuple.reAddRight();
childLeftTuple = childNext;
}
}
}
use of org.drools.core.reteoo.LeftTuple in project drools by kiegroup.
the class RuleNetworkEvaluator method doRiaNode.
private void doRiaNode(InternalAgenda agenda, PathMemory pmem, TupleSets<LeftTuple> srcTuples, BetaNode betaNode, LeftTupleSinkNode sink, SegmentMemory[] smems, int smemIndex, Memory nodeMem, BetaMemory bm, LinkedList<StackEntry> stack, RuleExecutor executor) {
RiaPathMemory pathMem = bm.getRiaRuleMemory();
SegmentMemory[] subnetworkSmems = pathMem.getSegmentMemories();
SegmentMemory subSmem = null;
for (int i = 0; subSmem == null; i++) {
// segment positions outside of the subnetwork, in the parent chain, are null
// so we must iterate to find the first non null segment memory
subSmem = subnetworkSmems[i];
}
// Resume the node after the riaNode segment has been processed and the right input memory populated
StackEntry stackEntry = new StackEntry(betaNode, bm.getNodePosMaskBit(), sink, pmem, nodeMem, smems, smemIndex, srcTuples, false, false);
stack.add(stackEntry);
if (log.isTraceEnabled()) {
int offset = getOffset(betaNode);
log.trace("{} RiaQueue {} {}", indent(offset), betaNode.toString(), srcTuples.toStringSizes());
}
TupleSets<LeftTuple> subLts = subSmem.getStagedLeftTuples().takeAll();
// node is first in the segment, so bit is 1
innerEval(pathMem, subSmem.getRootNode(), 1, subSmem.getNodeMemories().getFirst(), subnetworkSmems, subSmem.getPos(), subLts, agenda, stack, true, executor);
}
use of org.drools.core.reteoo.LeftTuple in project drools by kiegroup.
the class RuleNetworkEvaluator method doUpdatesReorderRightMemory.
public static void doUpdatesReorderRightMemory(BetaMemory bm, TupleSets<RightTuple> srcRightTuples) {
TupleMemory rtm = bm.getRightTupleMemory();
for (RightTuple rightTuple = srcRightTuples.getUpdateFirst(); rightTuple != null; rightTuple = rightTuple.getStagedNext()) {
if (rightTuple.getMemory() != null) {
rightTuple.setTempRightTupleMemory(rightTuple.getMemory());
rtm.remove(rightTuple);
}
}
for (RightTuple rightTuple = srcRightTuples.getUpdateFirst(); rightTuple != null; rightTuple = rightTuple.getStagedNext()) {
if (rightTuple.getTempRightTupleMemory() != null) {
rtm.add(rightTuple);
for (LeftTuple childLeftTuple = rightTuple.getFirstChild(); childLeftTuple != null; ) {
LeftTuple childNext = childLeftTuple.getRightParentNext();
childLeftTuple.reAddLeft();
childLeftTuple = childNext;
}
}
}
}
Aggregations