Package org.drools.reteoo.LeftInputAdapterNode

Examples of org.drools.reteoo.LeftInputAdapterNode.LiaNodeMemory


        out.writeObject( handle );
        out.writeObject( context );
    }

    public void doPropagation(InternalWorkingMemory workingMemory) {
        LiaNodeMemory memory = ( LiaNodeMemory ) workingMemory.getNodeMemory( node );
        if ( memory.getSegmentMemory() == null ) {
            SegmentUtilities.createSegmentMemory( node, workingMemory ); // initialises for all nodes in segment, including this one
        }
        node.getSinkPropagator().createAndPropagateAssertLeftTuple( handle,
                                                                    context,
                                                                    workingMemory,
View Full Code Here


        SegmentMemory smem = smems[smemIndex]; // 0
        LeftInputAdapterNode liaNode = (LeftInputAdapterNode) smem.getRootNode();

        LinkedList<Memory> nodeMemories = smem.getNodeMemories();

        LiaNodeMemory liaNodeMemory = (LiaNodeMemory) nodeMemories.getFirst();

        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
            nodeMem = smem.getNodeMemories().getFirst();
            node = smem.getRootNode();
        } else {
            node = (LeftTupleSource) liaNode.getSinkPropagator().getFirstLeftTupleSink(); // we know it can only have one child
            nodeMem = liaNodeMemory.getNext();
        }

        eval( node, nodeMem, smems, smemIndex, trgTuples, null, wm);

        return 0;
View Full Code Here

                    // NotNode's and Accumulate are initialised as linkedin
                    smem.linkNode( nodePosMask, wm );
                }
                nodePosMask = nodePosMask << 1;
            } else if ( tupleSource.getType() == NodeTypeEnums.LeftInputAdapterNode ) {               
                LiaNodeMemory liaMemory = ( LiaNodeMemory ) smem.createNodeMemory( ( LeftInputAdapterNode ) tupleSource, wm );
                liaMemory.setSegmentMemory( smem );
                liaMemory.setNodePosMaskBit( nodePosMask );
                allLinkedTestMask = allLinkedTestMask | nodePosMask;
   
                nodePosMask = nodePosMask << 1;               
            } else if ( tupleSource.getType() == NodeTypeEnums.EvalConditionNode ) {
                EvalMemory evalMemory = ( EvalMemory ) smem.createNodeMemory( ( EvalConditionNode ) tupleSource, wm );
View Full Code Here

        ReteooWorkingMemory wm = new ReteooWorkingMemory( 1, (ReteooRuleBase) RuleBaseFactory.newRuleBase((RuleBaseConfiguration)kconf) );
        SegmentUtilities.createSegmentMemory( liaNode, wm );
        liaNode.assertObject( (InternalFactHandle) wm.insert( "str" ), context, wm );
       

        LiaNodeMemory liaMem = (LiaNodeMemory) wm.getNodeMemory( liaNode );
        assertEquals( 1, liaMem.getNodePosMaskBit() );
        assertEquals( 3, liaMem.getSegmentMemory().getAllLinkedMaskTest() );
       
        BetaMemory bm1 = (BetaMemory) wm.getNodeMemory( n1 );
        assertEquals( 2, bm1.getNodePosMaskBit() );
        assertEquals( 3, bm1.getSegmentMemory().getAllLinkedMaskTest() );        
       
        // Initialise from n1    
        wm = new ReteooWorkingMemory( 1, (ReteooRuleBase) RuleBaseFactory.newRuleBase((RuleBaseConfiguration)kconf) );
        n1.assertObject( (InternalFactHandle) wm.insert( "str" ), context, wm );
       

        liaMem = (LiaNodeMemory) wm.getNodeMemory( liaNode );
        assertEquals( 1, liaMem.getNodePosMaskBit() );
        assertEquals( 3, liaMem.getSegmentMemory().getAllLinkedMaskTest() );
       
        bm1 = (BetaMemory) wm.getNodeMemory( n1 );
        assertEquals( 2, bm1.getNodePosMaskBit() );
        assertEquals( 3, bm1.getSegmentMemory().getAllLinkedMaskTest() );          
    }
View Full Code Here

        SegmentUtilities.createSegmentMemory( liaNode, wm );
       
        InternalFactHandle fh1 = (InternalFactHandle) wm.insert( "str1" );
        n1.assertObject( fh1, context, wm );   
       
        LiaNodeMemory liaMem = (LiaNodeMemory) wm.getNodeMemory( liaNode );
        assertEquals( 1, liaMem.getNodePosMaskBit() );
        assertEquals( 3, liaMem.getSegmentMemory().getAllLinkedMaskTest() );
       
        BetaMemory bm1 = (BetaMemory) wm.getNodeMemory( n1 );
        assertEquals( 2, bm1.getNodePosMaskBit() );
        assertEquals( 3, bm1.getSegmentMemory().getAllLinkedMaskTest() );    
       
        // still unlinked
        assertFalse( liaMem.getSegmentMemory().isSegmentLinked() );
       
        // now linked
        InternalFactHandle fh2 = (InternalFactHandle) wm.insert( "str2" );
        liaNode.assertObject( fh2, context, wm );
        assertTrue( liaMem.getSegmentMemory().isSegmentLinked() );
       
        // test unlink after one retract
        liaNode.retractLeftTuple( fh2.getFirstLeftTuple(), context, wm );
        assertFalse( liaMem.getSegmentMemory().isSegmentLinked() );
       
        // check counter, after multiple asserts
        InternalFactHandle fh3 = (InternalFactHandle) wm.insert( "str3" );
        InternalFactHandle fh4 = (InternalFactHandle) wm.insert( "str4" );
        liaNode.assertObject( fh3, context, wm );
        liaNode.assertObject( fh4, context, wm );
       
        assertTrue( liaMem.getSegmentMemory().isSegmentLinked() );
       
        liaNode.retractLeftTuple( fh3.getFirstLeftTuple(), context, wm );
        assertTrue( liaMem.getSegmentMemory().isSegmentLinked() );

        liaNode.retractLeftTuple( fh4.getFirstLeftTuple(), context, wm );
        assertFalse( liaMem.getSegmentMemory().isSegmentLinked() );
    }
View Full Code Here

        // retract any remaining LeftTuples
        if ( this.leftTuple != null ) {
            for ( LeftTuple current = this.leftTuple; current != null; current = (LeftTuple) current.getLeftParentNext() ) {
                if ( unlinkingEnabled ) {
                    LeftInputAdapterNode liaNode = (LeftInputAdapterNode) current.getLeftTupleSink().getLeftTupleSource();
                    LiaNodeMemory lm = ( LiaNodeMemory wm.getNodeMemory( liaNode );
                    LeftInputAdapterNode.doDeleteObject( current, context, lm.getSegmentMemory(), wm, liaNode, lm );
                } else {
                    current.getLeftTupleSink().retractLeftTuple( current,
                                                                 context,
                                                                 wm );                   
                }
View Full Code Here

                    // NotNode's and Accumulate are initialised as linkedin
                    smem.linkNode( nodePosMask, wm );
                }
                nodePosMask = nodePosMask << 1;
            } else if ( tupleSource.getType() == NodeTypeEnums.LeftInputAdapterNode ) {               
                LiaNodeMemory liaMemory = ( LiaNodeMemory ) smem.createNodeMemory( ( LeftInputAdapterNode ) tupleSource, wm );
                liaMemory.setSegmentMemory( smem );
                liaMemory.setNodePosMaskBit( nodePosMask );
                allLinkedTestMask = allLinkedTestMask | nodePosMask;
   
                nodePosMask = nodePosMask << 1;               
            } else if ( tupleSource.getType() == NodeTypeEnums.EvalConditionNode ) {
                EvalMemory evalMemory = ( EvalMemory ) smem.createNodeMemory( ( EvalConditionNode ) tupleSource, wm );
View Full Code Here

                    modifyPreviousTuples.removeLeftTuple();
                   
                   
                    if ( unlinkingEnabled ) {
                        LeftInputAdapterNode liaNode = (LeftInputAdapterNode) leftTuple.getLeftTupleSink().getLeftTupleSource();
                        LiaNodeMemory lm = ( LiaNodeMemory wm.getNodeMemory( liaNode );
                        LeftInputAdapterNode.doDeleteObject( leftTuple, context, lm.getSegmentMemory(), wm, liaNode, lm );
                    } else {
                        leftTuple.getLeftTupleSink().retractLeftTuple( leftTuple,
                                                                     context,
                                                                     wm );                   
                    }                  
View Full Code Here

TOP

Related Classes of org.drools.reteoo.LeftInputAdapterNode.LiaNodeMemory

Copyright © 2018 www.massapicom. 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.