Search in sources :

Example 6 with RiaNodeMemory

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;
}
Also used : RiaNodeMemory(org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory) Memory(org.drools.core.common.Memory) PathMemory(org.drools.core.reteoo.PathMemory) InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) SegmentNodeMemory(org.drools.core.reteoo.SegmentNodeMemory) ObjectTypeNodeMemory(org.drools.core.reteoo.ObjectTypeNode.ObjectTypeNodeMemory) RiaNodeMemory(org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory) AccumulateMemory(org.drools.core.reteoo.AccumulateNode.AccumulateMemory) TupleMemory(org.drools.core.reteoo.TupleMemory) BetaMemory(org.drools.core.reteoo.BetaMemory) SegmentMemory(org.drools.core.reteoo.SegmentMemory) FromMemory(org.drools.core.reteoo.FromNode.FromMemory) LeftTupleNode(org.drools.core.reteoo.LeftTupleNode) PathMemory(org.drools.core.reteoo.PathMemory)

Example 7 with RiaNodeMemory

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;
}
Also used : RiaNodeMemory(org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory) BetaMemory(org.drools.core.reteoo.BetaMemory) RightInputAdapterNode(org.drools.core.reteoo.RightInputAdapterNode)

Aggregations

RiaNodeMemory (org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory)7 RightInputAdapterNode (org.drools.core.reteoo.RightInputAdapterNode)6 BetaMemory (org.drools.core.reteoo.BetaMemory)5 PathMemory (org.drools.core.reteoo.PathMemory)5 LeftTupleSource (org.drools.core.reteoo.LeftTupleSource)4 ObjectSink (org.drools.core.reteoo.ObjectSink)4 Memory (org.drools.core.common.Memory)3 AccumulateMemory (org.drools.core.reteoo.AccumulateNode.AccumulateMemory)3 SegmentMemory (org.drools.core.reteoo.SegmentMemory)3 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)2 BetaNode (org.drools.core.reteoo.BetaNode)2 ConditionalBranchNode (org.drools.core.reteoo.ConditionalBranchNode)2 ConditionalBranchMemory (org.drools.core.reteoo.ConditionalBranchNode.ConditionalBranchMemory)2 EvalMemory (org.drools.core.reteoo.EvalConditionNode.EvalMemory)2 LeftInputAdapterNode (org.drools.core.reteoo.LeftInputAdapterNode)2 LiaNodeMemory (org.drools.core.reteoo.LeftInputAdapterNode.LiaNodeMemory)2 LeftTupleSink (org.drools.core.reteoo.LeftTupleSink)2 LeftTupleSinkNode (org.drools.core.reteoo.LeftTupleSinkNode)2 QueryElementNode (org.drools.core.reteoo.QueryElementNode)2 QueryElementNodeMemory (org.drools.core.reteoo.QueryElementNode.QueryElementNodeMemory)2