Package org.drools.common

Examples of org.drools.common.RightTupleSets


                           BetaMemory bm,
                           InternalWorkingMemory wm,
                           LeftTupleSets srcLeftTuples,
                           LeftTupleSets trgLeftTuples,
                           LeftTupleSets stagedLeftTuples) {
            RightTupleSets srcRightTuples = bm.getStagedRightTuples();

            if ( srcRightTuples.getDeleteFirst() != null ) {
                doRightDeletes( notNode, sink, bm, wm, srcRightTuples, trgLeftTuples );
            }

            if ( srcLeftTuples.getDeleteFirst() != null ) {
                doLeftDeletes( notNode, sink, bm, wm, srcLeftTuples, trgLeftTuples, stagedLeftTuples );
            }

            if ( srcLeftTuples.getUpdateFirst() != null || srcRightTuples.getUpdateFirst() != null ) {
                dpUpdatesReorderLeftMemory( bm,
                                        wm,
                                        srcRightTuples,
                                        srcLeftTuples );
                // don't re-order the right memory, as update relies on getting the next rightTuple before reAdd
            }

            if ( srcRightTuples.getUpdateFirst() != null ) {
                doRightUpdates( notNode, sink, bm, wm, srcRightTuples, trgLeftTuples, stagedLeftTuples );
            }

            // not nodes must do right inserts, before doing left updates. Otherwise you end up with child
            // in trgLeftTuples, and insert thinks it's staged in stagedLeftTuples giving nullpointer.
            if ( srcRightTuples.getInsertFirst() != null ) {
                doRightInserts( notNode, sink, bm, wm, srcRightTuples, trgLeftTuples );
            }
           
            if ( srcLeftTuples.getUpdateFirst() != null ) {
                doLeftUpdates( notNode, sink, bm, wm, srcLeftTuples, trgLeftTuples, stagedLeftTuples );
            }

            if ( srcLeftTuples.getInsertFirst() != null ) {
                doLeftInserts( notNode, sink, bm, wm, srcLeftTuples, trgLeftTuples );
            }
           
            srcRightTuples.resetAll();           
            srcLeftTuples.resetAll();            
        }
View Full Code Here


                           BetaMemory bm,
                           InternalWorkingMemory wm,
                           LeftTupleSets srcLeftTuples,
                           LeftTupleSets trgLeftTuples,
                           LeftTupleSets stagedLeftTuples) {
            RightTupleSets srcRightTuples = bm.getStagedRightTuples();

            if ( srcRightTuples.getDeleteFirst() != null ) {
                doRightDeletes( existsNode, bm, wm, srcRightTuples, trgLeftTuples, stagedLeftTuples );
            }

            if ( srcLeftTuples.getDeleteFirst() != null ) {
                doLeftDeletes( existsNode, bm, wm, srcLeftTuples, trgLeftTuples, stagedLeftTuples );
            }

            if ( srcLeftTuples.getUpdateFirst() != null || srcRightTuples.getUpdateFirst() != null ) {
                dpUpdatesReorderLeftMemory( bm,
                                        wm,
                                        srcRightTuples,
                                        srcLeftTuples );
            }

            if ( srcRightTuples.getUpdateFirst() != null ) {
                doRightUpdates( existsNode, sink, bm, wm, srcRightTuples, trgLeftTuples, stagedLeftTuples );
            }

            if ( srcLeftTuples.getUpdateFirst() != null ) {
                doLeftUpdates( existsNode, sink, bm, wm, srcLeftTuples, trgLeftTuples, stagedLeftTuples );
            }

            if ( srcRightTuples.getInsertFirst() != null ) {
                doRightInserts( existsNode, sink, bm, wm, srcRightTuples, trgLeftTuples );
            }

            if ( srcLeftTuples.getInsertFirst() != null ) {
                doLeftInserts( existsNode, sink, bm, wm, srcLeftTuples, trgLeftTuples );
            }
           
            srcRightTuples.resetAll();                        
            srcLeftTuples.resetAll( );            
        }
View Full Code Here

   

    public static void doDeleteRightTuple(final RightTuple rightTuple,
                                          final InternalWorkingMemory wm,
                                          final BetaMemory memory) {
        RightTupleSets stagedRightTuples = memory.getStagedRightTuples();

        switch ( rightTuple.getStagedType() ) {
            // handle clash with already staged entries
            case LeftTuple.INSERT:
                stagedRightTuples.removeInsert( rightTuple );
                break;
            case LeftTuple.UPDATE:
                stagedRightTuples.removeUpdate( rightTuple );
                break;
       
        
        if ( memory.getAndDecCounter() == 1 ) {
            memory.unlinkNode( wm );           
        } else if ( stagedRightTuples.deleteSize() == 0 ) {
            // nothing staged before, notify rule, so it can evaluate network
            memory.getSegmentMemory().notifyRuleLinkSegment( wm );
        }
       
        stagedRightTuples.addDelete( rightTuple );
    }  
View Full Code Here

    }  
   
    public void doUpdateRightTuple(final RightTuple rightTuple,
                                    final InternalWorkingMemory wm,
                                    final BetaMemory memory) {
       RightTupleSets stagedRightTuples = memory.getStagedRightTuples();
      
       if ( stagedRightTuples.updateSize() == 0 || stagedRightTuples.insertSize() == 0 ) {
           // also check inserts, as we'll leave it in insert stage list, if it has not yet been processed
           // nothing staged before, notify rule, so it can evaluate network
           memory.getSegmentMemory().notifyRuleLinkSegment( wm );
       }
      
       if ( rightTuple.getStagedType() == LeftTuple.NONE ) {
           // only stage, if it's not already staged
           stagedRightTuples.addUpdate( rightTuple );
       }      
   }     
View Full Code Here

                           InternalWorkingMemory wm,
                           LeftTupleSets srcLeftTuples,
                           LeftTupleSets trgLeftTuples,
                           LeftTupleSets stagedLeftTuples) {
            boolean useLeftMemory = true;
            RightTupleSets srcRightTuples = am.getBetaMemory().getStagedRightTuples();
           
            // We need to collect which leftTuple where updated, so that we can
            // add their result tuple to the real target tuples later
            LeftTupleSets tempLeftTuples = new LeftTupleSets();

            if ( srcLeftTuples.getDeleteFirst() != null ) {
                // use the real target here, as dealing direct with left tuples
                doLeftDeletes( accNode, am, wm, srcLeftTuples, trgLeftTuples );
            }
           
            if ( srcRightTuples.getDeleteFirst() != null ) {
                doRightDeletes( accNode, am, wm, srcRightTuples, tempLeftTuples );
            }           

            if ( srcLeftTuples.getUpdateFirst() != null || srcRightTuples.getUpdateFirst() != null ) {
                dpUpdatesReorderLeftMemory( am.getBetaMemory(), wm,
                                            srcRightTuples, srcLeftTuples );
                dpUpdatesReorderRightMemory( am.getBetaMemory(), wm,
                                             srcRightTuples, srcLeftTuples );               
            }
           
            if ( srcLeftTuples.getUpdateFirst() != null ) {
                doLeftUpdates( accNode, sink, am, wm, srcLeftTuples, tempLeftTuples );
            }           

            if ( srcRightTuples.getUpdateFirst() != null ) {
                doRightUpdates( accNode, sink, am, wm, srcRightTuples, tempLeftTuples );
            }

            if ( srcRightTuples.getInsertFirst() != null ) {
                doRightInserts( accNode, sink, am, wm, srcRightTuples, tempLeftTuples );
            }

            if ( srcLeftTuples.getInsertFirst() != null ) {
                doLeftInserts( accNode, sink, am, wm, srcLeftTuples, tempLeftTuples );
            }
           
            Accumulate accumulate = accNode.getAccumulate();
            // we do not need collect retracts. RightTuple retracts end up as updates for lefttuples.
            // LeftTuple retracts are already on the trgLeftTuples
            for ( LeftTuple leftTuple = tempLeftTuples.getInsertFirst(); leftTuple != null; ) {
                LeftTuple next = leftTuple.getStagedNext();
                evaluateResultConstraints( accNode, sink, accumulate, leftTuple, leftTuple.getPropagationContext(),
                                           wm, am, (AccumulateContext) leftTuple.getObject(), useLeftMemory,
                                           trgLeftTuples, stagedLeftTuples );
                leftTuple.clearStaged();
                leftTuple = next;               
            }
           
            for ( LeftTuple leftTuple = tempLeftTuples.getUpdateFirst(); leftTuple != null; ) {
                LeftTuple next = leftTuple.getStagedNext();
                evaluateResultConstraints( accNode, sink, accumulate, leftTuple, leftTuple.getPropagationContext(),
                                           wm, am, (AccumulateContext) leftTuple.getObject(), useLeftMemory,
                                           trgLeftTuples, stagedLeftTuples );
                leftTuple.clearStaged();
                leftTuple = next;                 
            }           
           
            srcRightTuples.resetAll();            
           
            srcLeftTuples.resetAll();           
        }
View Full Code Here

                           InternalWorkingMemory wm,
                           LeftTupleSets srcLeftTuples,
                           LeftTupleSets trgLeftTuples,
                           LeftTupleSets stagedLeftTuples) {
           
            RightTupleSets srcRightTuples = bm.getStagedRightTuples();

            if ( srcRightTuples.getDeleteFirst() != null ) {
                doRightDeletes( joinNode, bm, wm, srcRightTuples, trgLeftTuples, stagedLeftTuples );
            }

            if ( srcLeftTuples.getDeleteFirst() != null ) {
                doLeftDeletes( joinNode, bm, wm, srcLeftTuples, trgLeftTuples, stagedLeftTuples  );
            }

            if ( srcLeftTuples.getUpdateFirst() != null || srcRightTuples.getUpdateFirst() != null ) {
                dpUpdatesReorderLeftMemory( bm, wm,
                                            srcRightTuples, srcLeftTuples );
                dpUpdatesReorderRightMemory( bm, wm,
                                            srcRightTuples, srcLeftTuples );
            }

            if ( srcRightTuples.getUpdateFirst() != null ) {
                doRightUpdates( joinNode, sink, bm, wm, srcRightTuples, trgLeftTuples, stagedLeftTuples   );
            }

            if ( srcLeftTuples.getUpdateFirst() != null ) {
                doLeftUpdates( joinNode, sink, bm, wm, srcLeftTuples, trgLeftTuples, stagedLeftTuples   );
            }

            if ( srcRightTuples.getInsertFirst() != null ) {
                doRightInserts( joinNode, sink, bm, wm, srcRightTuples, trgLeftTuples  );
            }

            if ( srcLeftTuples.getInsertFirst() != null ) {
                doLeftInserts( joinNode, sink, bm, wm, srcLeftTuples, trgLeftTuples );
            }
           
            srcRightTuples.resetAll();           
            srcLeftTuples.resetAll();           
        }
View Full Code Here

                      final RightTupleMemory objectMemory,
                      final ContextEntry[] context,
                      final short nodeType) {
        this.leftTupleMemory = tupleMemory;
        this.rightTupleMemory = objectMemory;
        this.stagedRightTuples = new RightTupleSets();
        this.context = context;
        this.nodeType = nodeType;
    }
View Full Code Here

    public void retractRightTuple(final RightTuple rightTuple,
                                  final PropagationContext context,
                                  final InternalWorkingMemory workingMemory) {
        final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
        if ( isUnlinkingEnabled() ) {
            RightTupleSets stagedRightTuples = memory.getStagedRightTuples();
            switch ( rightTuple.getStagedType() ) {
                // handle clash with already staged entries
                case LeftTuple.INSERT:
                    stagedRightTuples.removeInsert( rightTuple );
                    break;
                case LeftTuple.UPDATE:
                    stagedRightTuples.removeUpdate( rightTuple );
                    break;
            }
           
            if memory.getAndDecCounter() == 1 && isEmptyBetaConstraints()  ) {
                // NotNodes can only be unlinked, if they have no variable constraints
                memory.linkNode( workingMemory );
            else if ( stagedRightTuples.deleteSize() == 0 ) {
                // nothing staged before, notify rule, so it can evaluate network
                memory.getSegmentMemory().notifyRuleLinkSegment( workingMemory );
            }
           
            stagedRightTuples.addDelete( rightTuple );
            return;
        }

        RightTupleMemory rightTupleMemory = memory.getRightTupleMemory();
        boolean useComparisonIndex = rightTupleMemory.getIndexType().isComparison();
View Full Code Here

TOP

Related Classes of org.drools.common.RightTupleSets

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.