Search in sources :

Example 6 with LeftTupleSinkNode

use of org.drools.core.reteoo.LeftTupleSinkNode in project drools by kiegroup.

the class ReactiveObjectUtil method notifyModification.

public static void notifyModification(Object object, Collection<Tuple> leftTuples, ModificationType type) {
    for (Tuple leftTuple : leftTuples) {
        if (!((ReactiveFromNodeLeftTuple) leftTuple).updateModificationState(object, type)) {
            continue;
        }
        PropagationContext propagationContext = leftTuple.getPropagationContext();
        ReactiveFromNode node = (ReactiveFromNode) leftTuple.getTupleSink();
        LeftTupleSinkNode sink = node.getSinkPropagator().getFirstLeftTupleSink();
        InternalWorkingMemory wm = getInternalWorkingMemory(propagationContext);
        wm.addPropagation(new ReactivePropagation(object, (ReactiveFromNodeLeftTuple) leftTuple, propagationContext, node, sink, type));
    }
}
Also used : InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) PropagationContext(org.drools.core.spi.PropagationContext) ReactiveFromNode(org.drools.core.reteoo.ReactiveFromNode) LeftTupleSinkNode(org.drools.core.reteoo.LeftTupleSinkNode) ReactiveFromNodeLeftTuple(org.drools.core.reteoo.ReactiveFromNodeLeftTuple) LeftTuple(org.drools.core.reteoo.LeftTuple) PhreakFromNode.deleteChildLeftTuple(org.drools.core.phreak.PhreakFromNode.deleteChildLeftTuple) Tuple(org.drools.core.spi.Tuple) ReactiveFromNodeLeftTuple(org.drools.core.reteoo.ReactiveFromNodeLeftTuple)

Example 7 with LeftTupleSinkNode

use of org.drools.core.reteoo.LeftTupleSinkNode in project drools by kiegroup.

the class RuleNetworkEvaluator method evalStackEntry.

public void evalStackEntry(StackEntry entry, LinkedList<StackEntry> stack, RuleExecutor executor, InternalAgenda agenda) {
    NetworkNode node = entry.getNode();
    Memory nodeMem = entry.getNodeMem();
    TupleSets<LeftTuple> trgTuples = entry.getTrgTuples();
    if (node.getType() == NodeTypeEnums.QueryElementNode) {
        // copy across the results, if any from the query node memory
        QueryElementNodeMemory qmem = (QueryElementNodeMemory) nodeMem;
        qmem.setNodeCleanWithoutNotify();
        qmem.getResultLeftTuples().addTo(trgTuples);
    }
    LeftTupleSinkNode sink = entry.getSink();
    PathMemory pmem = entry.getRmem();
    SegmentMemory[] smems = entry.getSmems();
    int smemIndex = entry.getSmemIndex();
    boolean processRian = entry.isProcessRian();
    long bit = entry.getBit();
    if (entry.isResumeFromNextNode()) {
        SegmentMemory smem = smems[smemIndex];
        if (node != smem.getTipNode()) {
            // get next node and node memory in the segment
            LeftTupleSink nextSink = sink.getNextLeftTupleSinkNode();
            if (nextSink == null) {
                node = sink;
            } else {
                // there is a nested subnetwork, take out path
                node = nextSink;
            }
            nodeMem = nodeMem.getNext();
            // update bit to new node
            bit = bit << 1;
        } else {
            // Reached end of segment, start on new segment.
            SegmentPropagator.propagate(smem, trgTuples, agenda.getWorkingMemory());
            smem = smems[++smemIndex];
            trgTuples = smem.getStagedLeftTuples().takeAll();
            node = smem.getRootNode();
            nodeMem = smem.getNodeMemories().getFirst();
            // update bit to start of new segment
            bit = 1;
        }
    }
    if (log.isTraceEnabled()) {
        int offset = getOffset(node);
        log.trace("{} Resume {} {}", indent(offset), node.toString(), trgTuples.toStringSizes());
    }
    innerEval(pmem, node, bit, nodeMem, smems, smemIndex, trgTuples, agenda, stack, processRian, executor);
}
Also used : SegmentMemory(org.drools.core.reteoo.SegmentMemory) Memory(org.drools.core.common.Memory) QueryElementNodeMemory(org.drools.core.reteoo.QueryElementNode.QueryElementNodeMemory) PathMemory(org.drools.core.reteoo.PathMemory) InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) ConditionalBranchMemory(org.drools.core.reteoo.ConditionalBranchNode.ConditionalBranchMemory) AccumulateMemory(org.drools.core.reteoo.AccumulateNode.AccumulateMemory) TupleMemory(org.drools.core.reteoo.TupleMemory) TimerNodeMemory(org.drools.core.reteoo.TimerNode.TimerNodeMemory) BetaMemory(org.drools.core.reteoo.BetaMemory) EvalMemory(org.drools.core.reteoo.EvalConditionNode.EvalMemory) SegmentMemory(org.drools.core.reteoo.SegmentMemory) FromMemory(org.drools.core.reteoo.FromNode.FromMemory) RiaPathMemory(org.drools.core.reteoo.RiaPathMemory) LeftTupleSink(org.drools.core.reteoo.LeftTupleSink) QueryElementNodeMemory(org.drools.core.reteoo.QueryElementNode.QueryElementNodeMemory) NetworkNode(org.drools.core.common.NetworkNode) LeftTuple(org.drools.core.reteoo.LeftTuple) LeftTupleSinkNode(org.drools.core.reteoo.LeftTupleSinkNode) PathMemory(org.drools.core.reteoo.PathMemory) RiaPathMemory(org.drools.core.reteoo.RiaPathMemory)

Aggregations

LeftTupleSinkNode (org.drools.core.reteoo.LeftTupleSinkNode)7 LeftTuple (org.drools.core.reteoo.LeftTuple)4 SegmentMemory (org.drools.core.reteoo.SegmentMemory)4 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)3 Memory (org.drools.core.common.Memory)2 AccumulateMemory (org.drools.core.reteoo.AccumulateNode.AccumulateMemory)2 BetaMemory (org.drools.core.reteoo.BetaMemory)2 BetaNode (org.drools.core.reteoo.BetaNode)2 ConditionalBranchMemory (org.drools.core.reteoo.ConditionalBranchNode.ConditionalBranchMemory)2 EvalMemory (org.drools.core.reteoo.EvalConditionNode.EvalMemory)2 LeftTupleSource (org.drools.core.reteoo.LeftTupleSource)2 PathMemory (org.drools.core.reteoo.PathMemory)2 QueryElementNodeMemory (org.drools.core.reteoo.QueryElementNode.QueryElementNodeMemory)2 TimerNodeMemory (org.drools.core.reteoo.TimerNode.TimerNodeMemory)2 QueryNameConstraint (org.drools.core.rule.constraint.QueryNameConstraint)2 NetworkNode (org.drools.core.common.NetworkNode)1 KnowledgeBaseImpl (org.drools.core.impl.KnowledgeBaseImpl)1 PhreakFromNode.deleteChildLeftTuple (org.drools.core.phreak.PhreakFromNode.deleteChildLeftTuple)1 ConditionalBranchNode (org.drools.core.reteoo.ConditionalBranchNode)1 FromMemory (org.drools.core.reteoo.FromNode.FromMemory)1