Examples of LeftTupleSource


Examples of org.drools.core.reteoo.LeftTupleSource

            while (tupleSource.getType() != NodeTypeEnums.LeftInputAdapterNode &&
                   SegmentUtilities.parentInSameSegment(tupleSource, null)) {
                tupleSource = tupleSource.getLeftTupleSource();
            }

            LeftTupleSource segmentRoot = tupleSource;
            int nodeTypesInSegment = 0;

            smem = restoreSegmentFromPrototype(wm, segmentRoot, nodeTypesInSegment);
            if ( smem != null ) {
                return smem;
            }

            smem = new SegmentMemory(segmentRoot);

            // Iterate all nodes on the same segment, assigning their position as a bit mask value
            // allLinkedTestMask is the resulting mask used to test if all nodes are linked in
            long nodePosMask = 1;
            long allLinkedTestMask = 0;
            boolean updateNodeBit = true// nodes after a branch CE can notify, but they cannot impact linking

            while (true) {
                nodeTypesInSegment = updateNodeTypesMask(tupleSource, nodeTypesInSegment);
                if ( tupleSource.isStreamMode() && smem.getStreamQueue() == null ) {
                    // need to make sure there is one Queue, for the rule, when a stream mode node is found.

                    StreamTupleEntryQueue queue = initAndGetTupleQueue(tupleSource, wm);
                    smem.setStreamQueue( queue );
                }
                if (NodeTypeEnums.isBetaNode(tupleSource)) {
                    allLinkedTestMask = processBetaNode(tupleSource, wm, smem, nodePosMask, allLinkedTestMask, updateNodeBit);
                } else {
                    switch (tupleSource.getType()) {
                        case NodeTypeEnums.LeftInputAdapterNode:
                            allLinkedTestMask = processLiaNode((LeftInputAdapterNode) tupleSource, wm, smem, nodePosMask, allLinkedTestMask);
                            break;
                        case NodeTypeEnums.EvalConditionNode:
                            processEvalNode((EvalConditionNode) tupleSource, wm, smem);
                            break;
                        case NodeTypeEnums.ConditionalBranchNode:
                            updateNodeBit = processBranchNode((ConditionalBranchNode) tupleSource, wm, smem);
                            break;
                        case NodeTypeEnums.FromNode:
                            processFromNode((FromNode) tupleSource, wm, smem);
                            break;
                        case NodeTypeEnums.TimerConditionNode:
                            processTimerNode((TimerNode) tupleSource, wm, smem, nodePosMask);
                            break;
                        case NodeTypeEnums.QueryElementNode:
                            updateNodeBit = processQueryNode((QueryElementNode) tupleSource, wm, segmentRoot, smem, nodePosMask);
                            break;
                    }
                }
                nodePosMask = nodePosMask << 1;

                if (tupleSource.getSinkPropagator().size() == 1) {
                    LeftTupleSinkNode sink = tupleSource.getSinkPropagator().getFirstLeftTupleSink();
                    if (NodeTypeEnums.isLeftTupleSource(sink)) {
                        tupleSource = (LeftTupleSource) sink;
                    } else {
                        // rtn or rian
                        // While not technically in a segment, we want to be able to iterate easily from the last node memory to the ria/rtn memory
                        // we don't use createNodeMemory, as these may already have been created by, but not added, by the method updateRiaAndTerminalMemory
                        Memory memory = wm.getNodeMemory((MemoryFactory) sink);
                        if (sink.getType() == NodeTypeEnums.RightInputAdaterNode) {
                            PathMemory riaPmem = ((RiaNodeMemory)memory).getRiaPathMemory();
                            smem.getNodeMemories().add( riaPmem );

                            RightInputAdapterNode rian = ( RightInputAdapterNode ) sink;
                            ObjectSink[] nodes = rian.getSinkPropagator().getSinks();
                            for ( ObjectSink node : nodes ) {
                                if ( NodeTypeEnums.isLeftTupleSource(node) )  {
                                    createSegmentMemory( (LeftTupleSource) node, wm );
                                }
                            }
                        } else if (NodeTypeEnums.isTerminalNode(sink)) {
                            smem.getNodeMemories().add(memory);
                        }
                        memory.setSegmentMemory(smem);
                        smem.setTipNode(sink);
                        break;
                    }
                } else {
                    // not in same segment
                    smem.setTipNode(tupleSource);
                    break;
                }
            }
            smem.setAllLinkedMaskTest(allLinkedTestMask);

            // iterate to find root and determine the SegmentNodes position in the RuleSegment
            LeftTupleSource pathRoot = segmentRoot;
            int ruleSegmentPosMask = 1;
            int counter = 0;
            while (pathRoot.getType() != NodeTypeEnums.LeftInputAdapterNode) {
                if (!SegmentUtilities.parentInSameSegment(pathRoot, null)) {
                    // for each new found segment, increase the mask bit position
                    ruleSegmentPosMask = ruleSegmentPosMask << 1;
                    counter++;
                }
                pathRoot = pathRoot.getLeftTupleSource();
            }
            smem.setSegmentPosMaskBit(ruleSegmentPosMask);
            smem.setPos(counter);

            if (smem.getRootNode().getType() != NodeTypeEnums.LeftInputAdapterNode &&
View Full Code Here

Examples of org.drools.core.reteoo.LeftTupleSource

            // Iterate to find outermost rianode
            RightInputAdapterNode riaNode = (RightInputAdapterNode) betaNode.getRightInput();
            //riaNode = getOuterMostRiaNode(riaNode, betaNode.getLeftTupleSource());

            // Iterat
            LeftTupleSource subnetworkLts = riaNode.getLeftTupleSource();
            while (subnetworkLts.getLeftTupleSource() != riaNode.getStartTupleSource()) {
                subnetworkLts = subnetworkLts.getLeftTupleSource();
            }

            Memory rootSubNetwokrMem = wm.getNodeMemory((MemoryFactory) subnetworkLts);
            SegmentMemory subNetworkSegmentMemory = rootSubNetwokrMem.getSegmentMemory();
            if (subNetworkSegmentMemory == null) {
View Full Code Here

Examples of org.drools.core.reteoo.LeftTupleSource

     * @param riaNode
     * @param leftTupleSource
     * @return
     */
    public static boolean inSubNetwork(RightInputAdapterNode riaNode, LeftTupleSource leftTupleSource) {
        LeftTupleSource startTupleSource = riaNode.getStartTupleSource();
        LeftTupleSource parent = riaNode.getLeftTupleSource();

        while (parent != startTupleSource) {
            if (parent == leftTupleSource) {
                return true;
            }
            parent = parent.getLeftTupleSource();
        }

        return false;
    }
View Full Code Here

Examples of org.drools.reteoo.LeftTupleSource

        // get builder for the pattern
        final ReteooComponentBuilder builder = utils.getBuilderFor( sourcePattern );

        // save tuple source and pattern offset for later if needed
        final LeftTupleSource tupleSource = context.getTupleSource();
        final int currentPatternIndex = context.getCurrentPatternOffset();

        // builds the source pattern
        builder.build( context,
                       utils,
View Full Code Here

Examples of org.drools.reteoo.LeftTupleSource

        // get builder for the pattern
        final ReteooComponentBuilder builder = utils.getBuilderFor( source );

        // save tuple source and current pattern offset for later if needed
        LeftTupleSource tupleSource = context.getTupleSource();
        final int currentPatternIndex = context.getCurrentPatternOffset();
       
        // builds the source pattern
        builder.build( context,
                       utils,
View Full Code Here

Examples of org.drools.reteoo.LeftTupleSource

            boolean existSubNetwort = false;
            final GroupElement not = (GroupElement) rce;

            // NOT must save some context info to restore it later
            final int currentPatternIndex = context.getCurrentPatternOffset();
            final LeftTupleSource tupleSource = context.getTupleSource();

            // get child
            final RuleConditionElement child = not.getChildren().get( 0 );

            // get builder for child
View Full Code Here

Examples of org.drools.reteoo.LeftTupleSource

            boolean existSubNetwort = false;           
            final GroupElement exists = (GroupElement) rce;

            // EXISTS must save some context info to restore it later
            final int currentPatternIndex = context.getCurrentPatternOffset();
            final LeftTupleSource tupleSource = context.getTupleSource();

            // get child
            final RuleConditionElement child = exists.getChildren().get( 0 );

            // get builder for child
View Full Code Here

Examples of org.drools.reteoo.LeftTupleSource

                                             LeftTupleSink         node) {
        return new LeftTupleIterator(wm, node);
    }

    public void setFirstLeftTupleForNode() {
        LeftTupleSource source = node.getLeftTupleSource();

        this.currentLeftTuple = getFirstLeftTuple( source,
                                                   (LeftTupleSink) node,
                                                   wm );
    }
View Full Code Here

Examples of org.drools.reteoo.LeftTupleSource

        }
        return null;
    }

    public void setNextLeftTuple() {
        LeftTupleSource source = node.getLeftTupleSource();
        currentLeftTuple = getNextLeftTuple( source,
                                             (LeftTupleSink) node,
                                             currentLeftTuple,
                                             wm );
    }
View Full Code Here

Examples of org.drools.reteoo.LeftTupleSource

        StagedLeftTuples trgTuples = new StagedLeftTuples();
        StagedLeftTuples srcTuples = smem.getStagedLeftTuples();
        pLiaNode.doNode( liaNode, liaNodeMemory, wm, srcTuples, trgTuples );

        LeftTupleSource node = null;
        Memory nodeMem = null;
        if ( liaNode == smem.getTipNode() ) {
            // Segment only contains LiaNode, so need to propagate peers
            SegmentPropagator.propagate( smem, trgTuples, wm );
            smem = smems[smemIndex]; // 1
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.