use of org.drools.core.common.NetworkNode in project drools by kiegroup.
the class RuleNetworkEvaluator method evaluateNetwork.
public void evaluateNetwork(PathMemory pmem, RuleExecutor executor, InternalAgenda agenda) {
SegmentMemory[] smems = pmem.getSegmentMemories();
int smemIndex = 0;
// 0
SegmentMemory smem = smems[smemIndex];
LeftInputAdapterNode liaNode = (LeftInputAdapterNode) smem.getRootNode();
LinkedList<StackEntry> stack = new LinkedList<StackEntry>();
NetworkNode node;
Memory nodeMem;
long bit = 1;
if (liaNode == smem.getTipNode()) {
// segment only has liaNode in it
// nothing is staged in the liaNode, so skip to next segment
// 1
smem = smems[++smemIndex];
node = smem.getRootNode();
nodeMem = smem.getNodeMemories().getFirst();
} else {
// lia is in shared segment, so point to next node
bit = 2;
node = liaNode.getSinkPropagator().getFirstLeftTupleSink();
// skip the liaNode memory
nodeMem = smem.getNodeMemories().getFirst().getNext();
}
TupleSets<LeftTuple> srcTuples = smem.getStagedLeftTuples();
if (log.isTraceEnabled()) {
log.trace("Rule[name={}] segments={} {}", ((TerminalNode) pmem.getPathEndNode()).getRule().getName(), smems.length, srcTuples.toStringSizes());
}
outerEval(pmem, node, bit, nodeMem, smems, smemIndex, srcTuples, agenda, stack, true, executor);
}
use of org.drools.core.common.NetworkNode in project drools by kiegroup.
the class QueryTerminalNodeVisitor method doVisit.
@Override
protected void doVisit(NetworkNode node, Stack<NetworkNode> nodeStack, StatefulKnowledgeSessionInfo info) {
QueryTerminalNode rtn = (QueryTerminalNode) node;
RuleImpl rule = rtn.getRule();
// first thing, associate all nodes belonging to this rule
for (NetworkNode snode : nodeStack) {
info.assign(snode, rule);
}
// Query Terminal Nodes no longer have memory
// TODO delete this
// final LinkedList<?> memory = (LinkedList<?>) info.getSession().getNodeMemory( rtn );
// final DefaultNodeInfo ni = (DefaultNodeInfo) info.getNodeInfo( node );
// ni.setMemoryEnabled( true );
// ni.setTupleMemorySize( memory.size() );
}
use of org.drools.core.common.NetworkNode in project drools by kiegroup.
the class RuleTerminalNodeVisitor method doVisit.
@Override
protected void doVisit(NetworkNode node, Stack<NetworkNode> nodeStack, StatefulKnowledgeSessionInfo info) {
RuleTerminalNode rtn = (RuleTerminalNode) node;
RuleImpl rule = rtn.getRule();
// first thing, associate all nodes belonging to this rule
for (NetworkNode snode : nodeStack) {
info.assign(snode, rule);
}
final DefaultNodeInfo ni = (DefaultNodeInfo) info.getNodeInfo(node);
ni.setMemoryEnabled(false);
}
use of org.drools.core.common.NetworkNode in project drools by kiegroup.
the class SessionInspector method gatherNodeInfo.
private void gatherNodeInfo(NetworkNode parent, Stack<NetworkNode> nodeStack, StatefulKnowledgeSessionInfo info) {
if (!info.visited(parent)) {
nodeStack.push(parent);
NetworkNodeVisitor visitor = visitors.get(parent.getType());
if (visitor != null) {
visitor.visit(parent, nodeStack, info);
} else {
throw new RuntimeException("No visitor found for node class: " + parent.getClass() + " node: " + parent);
}
visitChildren(parent, nodeStack, info);
nodeStack.pop();
} else {
// if already visited, then assign the same rules to the nodes currently in the stack
Set<RuleImpl> rules = info.getNodeInfo(parent).getRules();
for (NetworkNode snode : nodeStack) {
for (RuleImpl rule : rules) {
info.assign(snode, rule);
}
}
}
}
use of org.drools.core.common.NetworkNode in project drools by kiegroup.
the class RuleTerminalNodeVisitor method doVisit.
@Override
protected void doVisit(NetworkNode node, Stack<NetworkNode> nodeStack, StatefulKnowledgeSessionInfo info) {
RuleTerminalNode rtn = (RuleTerminalNode) node;
RuleImpl rule = rtn.getRule();
// first thing, associate all nodes belonging to this rule
for (NetworkNode snode : nodeStack) {
info.assign(snode, rule);
}
final DefaultNodeInfo ni = (DefaultNodeInfo) info.getNodeInfo(node);
ni.setMemoryEnabled(false);
}
Aggregations