use of org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory in project drools by kiegroup.
the class AddRemoveRule method getPathEndMemories.
private static PathEndNodeMemories getPathEndMemories(InternalWorkingMemory wm, PathEndNodes pathEndNodes) {
PathEndNodeMemories tnMems = new PathEndNodeMemories();
for (LeftTupleNode node : pathEndNodes.otherEndNodes) {
if (node.getType() == NodeTypeEnums.RightInputAdaterNode) {
RiaNodeMemory riaMem = (RiaNodeMemory) wm.getNodeMemories().peekNodeMemory(node);
if (riaMem != null) {
tnMems.otherPmems.add(riaMem.getRiaPathMemory());
}
} else {
PathMemory pmem = (PathMemory) wm.getNodeMemories().peekNodeMemory(node);
if (pmem != null) {
tnMems.otherPmems.add(pmem);
}
}
}
tnMems.subjectPmem = (PathMemory) wm.getNodeMemories().peekNodeMemory(pathEndNodes.subjectEndNode);
if (tnMems.subjectPmem == null && !tnMems.otherPmems.isEmpty()) {
// If "other pmem's are initialized, then the subject needs to be initialized too.
tnMems.subjectPmem = (PathMemory) wm.getNodeMemory((MemoryFactory<Memory>) pathEndNodes.subjectEndNode);
}
for (LeftTupleNode node : pathEndNodes.subjectEndNodes) {
if (node.getType() == NodeTypeEnums.RightInputAdaterNode) {
RiaNodeMemory riaMem = (RiaNodeMemory) wm.getNodeMemories().peekNodeMemory(node);
if (riaMem == null && !tnMems.otherPmems.isEmpty()) {
riaMem = (RiaNodeMemory) wm.getNodeMemory((MemoryFactory<Memory>) node);
}
if (riaMem != null) {
tnMems.subjectPmems.add(riaMem.getRiaPathMemory());
}
} else {
PathMemory pmem = (PathMemory) wm.getNodeMemories().peekNodeMemory(node);
if (pmem != null) {
tnMems.subjectPmems.add(pmem);
}
}
}
return tnMems;
}
use of org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory in project drools by kiegroup.
the class SegmentUtilities method processBetaNode.
private static long processBetaNode(BetaNode betaNode, ReteEvaluator reteEvaluator, SegmentMemory smem, long nodePosMask, long allLinkedTestMask, boolean updateNodeBit) {
BetaMemory bm = NodeTypeEnums.AccumulateNode == betaNode.getType() ? ((AccumulateMemory) smem.createNodeMemory(betaNode, reteEvaluator)).getBetaMemory() : (BetaMemory) smem.createNodeMemory(betaNode, reteEvaluator);
// this must be set first, to avoid recursion as sub networks can be initialised multiple ways
// and bm.getSegmentMemory == null check can be used to avoid recursion.
bm.setSegmentMemory(smem);
if (betaNode.isRightInputIsRiaNode()) {
RightInputAdapterNode riaNode = createRiaSegmentMemory(betaNode, reteEvaluator);
RiaNodeMemory riaMem = reteEvaluator.getNodeMemory(riaNode);
bm.setRiaRuleMemory(riaMem.getRiaPathMemory());
if (updateNodeBit && canBeDisabled(betaNode) && riaMem.getRiaPathMemory().getAllLinkedMaskTest() > 0) {
// only ria's with reactive subnetworks can be disabled and thus need checking
allLinkedTestMask = allLinkedTestMask | nodePosMask;
}
} else if (updateNodeBit && canBeDisabled(betaNode)) {
allLinkedTestMask = allLinkedTestMask | nodePosMask;
}
bm.setNodePosMaskBit(nodePosMask);
if (NodeTypeEnums.NotNode == betaNode.getType()) {
// not nodes start up linked in
smem.linkNodeWithoutRuleNotify(bm.getNodePosMaskBit());
}
return allLinkedTestMask;
}
Aggregations