Package org.drools.core.reteoo

Examples of org.drools.core.reteoo.JoinNode


                .getReteooBuilder().getIdGenerator() );
        buildContext.setTupleMemoryEnabled( false );
        buildContext.setObjectTypeNodeMemoryEnabled( false );

        // override setup, so its working in sequential mode
        this.node = new JoinNode(
                                  15,
                                  this.tupleSource,
                                  this.objectSource,
                                  new DefaultBetaConstraints(
                                                              new BetaNodeFieldConstraint[]{this.constraint}, conf ),
View Full Code Here


        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory
                .newRuleBase();
        BuildContext buildContext = new BuildContext( ruleBase, ruleBase
                .getReteooBuilder().getIdGenerator() );

        final JoinNode joinNode = new JoinNode( 1, this.tupleSource,
                                                this.objectSource, EmptyBetaConstraints.getInstance(),
                                                buildContext );

        // Add the first tuple sink and assert a tuple and object
        // The sink has no memory
        final MockLeftTupleSink sink1 = new MockLeftTupleSink( 2 );
        joinNode.addTupleSink( sink1 );

        final DefaultFactHandle f0 = new DefaultFactHandle( 0, "string0" );

        final LeftTupleImpl tuple1 = new LeftTupleImpl( f0, this.node, true );

        joinNode.assertLeftTuple( tuple1,
                                  this.context,
                                  workingMemory );

        final String string1 = "string1";
        final DefaultFactHandle string1Handle = new DefaultFactHandle( 1,
                                                                       string1 );

        joinNode.assertObject( string1Handle,
                               this.context,
                               workingMemory );

        assertLength( 1,
                      sink1.getAsserted() );

        // Add the new sink, this should be updated from the re-processed
        // joinnode memory
        final MockLeftTupleSink sink2 = new MockLeftTupleSink( 3 );
        assertLength( 0,
                      sink2.getAsserted() );

        joinNode.updateSink( sink2,
                             this.context,
                             workingMemory );

        assertLength( 1,
                      sink2.getAsserted() );
View Full Code Here

        str += "    intValue, !=, p1;\n";

        NodeTestResult result = executeTest( str );
        Map<String, Object> map = result.context;

        JoinNode join1 = (JoinNode) map.get( "join1" );
        assertNotNull( join1 );

        InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();

        PropagationContextFactory pctxFactory = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();

        PropagationContext context = pctxFactory.createPropagationContext(0, PropagationContext.INSERTION, null, null, null);
        StatefulKnowledgeSessionImpl workingMemory = new StatefulKnowledgeSessionImpl( 1, kBase );

        BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( join1 );

        final DefaultFactHandle f0 = new DefaultFactHandle( 0,
                                                            0 );
        final LeftTupleImpl tuple0 = new LeftTupleImpl( f0,
                                                join1,
                                                true );

        // assert tuple, should add one to left memory
        join1.assertLeftTuple( tuple0,
                               context,
                               workingMemory );
        // check memories, left memory is populated, right memory is emptys
        assertEquals( 1,
                      memory.getLeftTupleMemory().size() );
        assertEquals( 0,
                      memory.getRightTupleMemory().size() );

        // assert tuple, should add left memory should be 2
        final DefaultFactHandle f1 = new DefaultFactHandle( 1,
                                                            0 );
        final LeftTupleImpl tuple1 = new LeftTupleImpl( f1,
                                                join1,
                                                true );
        join1.assertLeftTuple( tuple1,
                               context,
                               workingMemory );
        assertEquals( 2,
                      memory.getLeftTupleMemory().size() );
View Full Code Here

        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory
                .newRuleBase();
        BuildContext buildContext = new BuildContext(ruleBase, ruleBase
                .getReteooBuilder().getIdGenerator());

        final JoinNode joinNode = new JoinNode(1, this.tupleSource,
                this.objectSource, EmptyBetaConstraints.getInstance(), buildContext);

        // Add the first tuple sink and assert a tuple and object
        // The sink has no memory
        final MockLeftTupleSink sink1 = new MockLeftTupleSink(2);
        joinNode.addTupleSink(sink1);

        final DefaultFactHandle f0 = new DefaultFactHandle(0, "string0");

        final LeftTupleImpl tuple1 = new LeftTupleImpl(f0, this.node, true);

        joinNode.assertLeftTuple(tuple1, this.context, workingMemory);

        final String string1 = "string1";
        final DefaultFactHandle string1Handle = new DefaultFactHandle(1, string1);

        ModifyPreviousTuples modifyPreviousTuples = new ModifyPreviousTuples(null, null, new EntryPointNode() );

        assertLength(0, sink1.getAsserted());

        joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPassNothing, workingMemory);
        assertLength(0, sink1.getAsserted());

        joinNode.setRightDeclaredMask(0);
        joinNode.initInferredMask();
        joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPass2And3, workingMemory);
        assertLength(0, sink1.getAsserted());

        joinNode.setRightDeclaredMask(9);
        joinNode.initInferredMask();
        joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPass2And3, workingMemory);
        assertLength(0, sink1.getAsserted());

        joinNode.setRightDeclaredMask(3);
        joinNode.initInferredMask();
        joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPass2And3, workingMemory);
        assertLength(1, sink1.getAsserted());

        joinNode.modifyObject(string1Handle, modifyPreviousTuples, contextPassAll, workingMemory);
        assertLength(2, sink1.getAsserted());
    }
View Full Code Here

        NodeTestResult result = executeTest( str );
        Map<String, Object> map = result.context;

        InternalWorkingMemory wm = (InternalWorkingMemory) map.get( "WorkingMemory" );

        JoinNode join1 = (JoinNode) map.get( "join1" );

        BetaMemory memory = (BetaMemory) wm.getNodeMemory( join1 );
        assertEquals( 2,
                      memory.getRightTupleMemory().size() );
View Full Code Here

        Map<String, Object> map = result.context;

        InternalWorkingMemory wm = (InternalWorkingMemory) map.get( "WorkingMemory" );
        List<InternalFactHandle> handles = (List<InternalFactHandle>) map.get( "Handles" );

        JoinNode join1 = (JoinNode) map.get( "join1" );

        BetaMemory memory = (BetaMemory) wm.getNodeMemory( join1 );
        assertEquals( 1,
                      memory.getRightTupleMemory().size() );
View Full Code Here

        Map<String, Object> map = result.context;

        InternalWorkingMemory wm = (InternalWorkingMemory) map.get( "WorkingMemory" );
        List<InternalFactHandle> handles = (List<InternalFactHandle>) map.get( "Handles" );

        JoinNode join1 = (JoinNode) map.get( "join1" );

        BetaMemory memory = (BetaMemory) wm.getNodeMemory( join1 );
        assertEquals( 1,
                      memory.getRightTupleMemory().size() );
View Full Code Here

        Map<String, Object> map = result.context;

        InternalWorkingMemory wm = (InternalWorkingMemory) map.get( "WorkingMemory" );
        List<InternalFactHandle> handles = (List<InternalFactHandle>) map.get( "Handles" );

        JoinNode join1 = (JoinNode) map.get( "join1" );

        BetaMemory memory = (BetaMemory) wm.getNodeMemory( join1 );
        assertEquals( 1,
                      memory.getRightTupleMemory().size() );
View Full Code Here

        Map<String, Object> map = result.context;

        InternalWorkingMemory wm = (InternalWorkingMemory) map.get( "WorkingMemory" );
        List<InternalFactHandle> handles = (List<InternalFactHandle>) map.get( "Handles" );

        JoinNode join1 = (JoinNode) map.get( "join1" );

        BetaMemory memory = (BetaMemory) wm.getNodeMemory( join1 );
        assertEquals( 1,
                      memory.getRightTupleMemory().size() );
View Full Code Here

        Map<String, Object> map = result.context;

        InternalWorkingMemory wm = (InternalWorkingMemory) map.get( "WorkingMemory" );
        List<InternalFactHandle> handles = (List<InternalFactHandle>) map.get( "Handles" );

        JoinNode join1 = (JoinNode) map.get( "join1" );

        BetaMemory memory = (BetaMemory) wm.getNodeMemory( join1 );
        assertEquals( 2,
                      memory.getRightTupleMemory().size() );

        assertEquals( 3,
                      memory.getLeftTupleMemory().size() );
       
        JoinNode join2 = (JoinNode) map.get( "join2" );

        memory = (BetaMemory) wm.getNodeMemory( join2 );
        assertEquals( 0,
                      memory.getRightTupleMemory().size() );
View Full Code Here

TOP

Related Classes of org.drools.core.reteoo.JoinNode

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.