Package org.drools.core.reteoo

Examples of org.drools.core.reteoo.LeftTuple


        public void execute(JobContext ctx) {
            final TimerNodeJobContext timerJobCtx = (TimerNodeJobContext) ctx;
            Trigger trigger = timerJobCtx.getTrigger();

            LeftTupleList leftTuples = timerJobCtx.getTimerNodeMemory().getInsertOrUpdateLeftTuples();
            LeftTuple lt = timerJobCtx.getLeftTuple();

            if ( log.isTraceEnabled() ) {
                log.trace( "Timer Executor {} {}", timerJobCtx.getTrigger(), lt );
            }

            synchronized ( leftTuples ) {
                if ( timerJobCtx.getJobHandle().isCancel() ) {
                    // this is to force a sync point, as during update propagate it can cancel the FH
                    // we cannot have an update processed at the same timer is firing
                    return;
                }
                if ( lt.getMemory() == null ) {
                    // don't add it, if it's already added, which could happen with interval or cron timers
                    leftTuples.add( lt );
                }
            }
View Full Code Here


            LeftInputAdapterNode lian = ( LeftInputAdapterNode ) factHandle.getFirstLeftTuple().getLeftTupleSink().getLeftTupleSource();
            LeftInputAdapterNode.LiaNodeMemory lmem = (LeftInputAdapterNode.LiaNodeMemory) getNodeMemory( (MemoryFactory) lian);
            SegmentMemory lsmem = lmem.getSegmentMemory();

            LeftTuple childLeftTuple = factHandle.getFirstLeftTuple(); // there is only one, all other LTs are peers
            LeftInputAdapterNode.doDeleteObject( childLeftTuple, childLeftTuple.getPropagationContext(),  lsmem, this, lian, false, lmem );

            List<PathMemory> pmems =  lmem.getSegmentMemory().getPathMemories();
            for ( int i = 0, length = pmems.size(); i < length; i++ ) {
                PathMemory rm = pmems.get( i );
View Full Code Here

        public int compare(org.drools.core.spi.Activation o1,
                           org.drools.core.spi.Activation o2) {
            int result = o1.getRule().getName().compareTo( o2.getRule().getName() );
            if ( result == 0 ) {
                LeftTuple t1 = o1.getTuple();
                LeftTuple t2 = o2.getTuple();
                while ( result == 0 && t1 != null && t2 != null ) {
                    if ( t1.getLastHandle() != null && t2.getLastHandle() != null ) {
                        // can be null for eval, not and exists that have no right input
                        result = t1.getLastHandle().getId() - t2.getLastHandle().getId();
                    }
                    t1 = t1.getParent();
                    t2 = t2.getParent();
                }
            }
            return result;
        }
View Full Code Here

            ProtobufMessages.NodeMemory.RIANodeMemory.Builder _ria = ProtobufMessages.NodeMemory.RIANodeMemory.newBuilder();
            final org.drools.core.util.Iterator it = bm.getRightTupleMemory().iterator();

            // iterates over all propagated handles and assert them to the new sink
            for ( RightTuple entry = (RightTuple) it.next(); entry != null; entry = (RightTuple) it.next() ) {
                LeftTuple leftTuple = (LeftTuple) entry.getFactHandle().getObject();
                InternalFactHandle handle = (InternalFactHandle) leftTuple.getObject();
                FactHandle _handle = ProtobufMessages.FactHandle.newBuilder()
                        .setId( handle.getId() )
                        .setRecency( handle.getRecency() )
                        .build();
                _ria.addContext( ProtobufMessages.NodeMemory.RIANodeMemory.RIAContext.newBuilder()
View Full Code Here

            ProtobufMessages.NodeMemory.QueryElementNodeMemory.QueryContext.Builder _context = ProtobufMessages.NodeMemory.QueryElementNodeMemory.QueryContext.newBuilder()
                    .setTuple( PersisterHelper.createTuple( leftTuple ) )
                    .setHandle( _handle );

            LeftTuple childLeftTuple = leftTuple.getFirstChild();
            while ( childLeftTuple != null ) {
                RightTuple rightParent = childLeftTuple.getRightParent();
                _context.addResult( ProtobufMessages.FactHandle.newBuilder()
                        .setId( rightParent.getFactHandle().getId() )
                        .setRecency( rightParent.getFactHandle().getRecency() )
                        .build() );
                while ( childLeftTuple != null && childLeftTuple.getRightParent() == rightParent ) {
                    // skip to the next child that has a different right parent
                    childLeftTuple = childLeftTuple.getLeftParentNext();
                }
            }
            _query.addContext( _context.build() );
        }
View Full Code Here

            }
        }

        @Override
        public boolean accept(Match match) {
            LeftTuple tuple = ((Activation)match).getTuple();
            ActivationKey key = PersisterHelper.createActivationKey( match.getRule().getPackageName(),
                                                                     match.getRule().getName(),
                                                                     tuple );
            // add the tuple to the cache for correlation
            this.tuplesCache.put( key, tuple );
View Full Code Here

         str += "end  \n";
         KnowledgeBase kbase = loadKnowledgeBaseFromString( RuleEngineOption.PHREAK, str );
         StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );
         DefaultFactHandle handle = (DefaultFactHandle) ksession.insert( "hello" );
         ksession.fireAllRules();
         LeftTuple leftTuple = handle.getFirstLeftTuple();
         assertNotNull( leftTuple );
         assertNotNull( leftTuple.getPeer() );
         kbase.removeRule( "org.drools.compiler",
                           "rule2" );
         leftTuple = handle.getFirstLeftTuple();
         assertNotNull( leftTuple );
         assertNull( leftTuple.getLeftParentNext() );
     }
View Full Code Here

                                                     leftTuple)) {
                    if (leftTuple.getStagedType() == LeftTuple.NONE) {
                        trgLeftTuples.addUpdate(leftTuple);
                    }
                    final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
                    LeftTuple temp = null;
                    if (childLeftTuple != null && childLeftTuple.getLeftParent() == leftTuple) {
                        temp = childLeftTuple.getRightParentNext();
                        // we must re-add this to ensure deterministic iteration
                        childLeftTuple.reAddLeft();
                        removeMatch(accNode,
                                    accumulate,
                                    rightTuple,
                                    childLeftTuple,
                                    wm,
                                    am,
                                    accctx,
                                    true);
                        childLeftTuple = temp;
                    }
                    // add a new match
                    addMatch(accNode,
                             accumulate,
                             leftTuple,
                             rightTuple,
                             null,
                             childLeftTuple,
                             wm,
                             am,
                             accctx,
                             true);
                    if (temp != null) {
                        childLeftTuple = temp;
                    }
                } else if (childLeftTuple != null && childLeftTuple.getLeftParent() == leftTuple) {
                    if (leftTuple.getStagedType() == LeftTuple.NONE) {
                        trgLeftTuples.addUpdate(leftTuple);
                    }

                    LeftTuple temp = childLeftTuple.getRightParentNext();
                    final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
                    // remove the match
                    removeMatch(accNode,
                                accumulate,
                                rightTuple,
View Full Code Here

        LeftTupleMemory ltm = bm.getLeftTupleMemory();
        //ContextEntry[] contextEntry = bm.getContext();
        Accumulate accumulate = accNode.getAccumulate();

        for (LeftTuple leftTuple = srcLeftTuples.getDeleteFirst(); leftTuple != null; ) {
            LeftTuple next = leftTuple.getStagedNext();
            if (leftTuple.getMemory() != null) {
                // it may have been staged and never actually added
                ltm.remove(leftTuple);

View Full Code Here

            if (rightTuple.getMemory() != null) {
                // it may have been staged and never actually added
                rtm.remove(rightTuple);

                if (rightTuple.getFirstChild() != null) {
                    LeftTuple match = rightTuple.getFirstChild();

                    while (match != null) {
                        LeftTuple nextLeft = match.getRightParentNext();

                        LeftTuple leftTuple = match.getLeftParent();
                        final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
                        removeMatch(accNode, accumulate, rightTuple, match, wm, am, accctx, true);

                        if (leftTuple.getStagedType() == LeftTuple.NONE) {
                            trgLeftTuples.addUpdate(leftTuple);
                        }


                        match = nextLeft;
View Full Code Here

TOP

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

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.