Examples of RightTupleSets


Examples of org.drools.core.common.RightTupleSets

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


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

        if (srcLeftTuples.getUpdateFirst() != null )  {
            RuleNetworkEvaluator.dpUpdatesExistentialReorderLeftMemory(bm,
                                                                       srcLeftTuples);
        }

        if ( srcRightTuples.getUpdateFirst() != null ) {
            RuleNetworkEvaluator.dpUpdatesExistentialReorderRightMemory(bm,
                                                                        existsNode,
                                                                        srcRightTuples); // this also preserves the next rightTuple
        }

        if (srcRightTuples.getInsertFirst() != null) {
            // left deletes must come before right deletes. Otherwise right deletes could
            // stage a deletion, that is later deleted in the rightDelete, causing potential problems
            doRightInserts(existsNode, sink, bm, wm, srcRightTuples, trgLeftTuples);
        }

        if (srcRightTuples.getUpdateFirst() != null) {
            // must come after rightInserts and before rightDeletes, to avoid staging clash
            doRightUpdates(existsNode, sink, bm, wm, srcRightTuples, trgLeftTuples, stagedLeftTuples);
        }

        if (srcRightTuples.getDeleteFirst() != null) {
            // must come after rightUpdetes, to avoid staging clash
            doRightDeletes(existsNode, bm, wm, srcRightTuples, trgLeftTuples, stagedLeftTuples);
        }


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

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

        srcRightTuples.resetAll();
        srcLeftTuples.resetAll();
    }
View Full Code Here

Examples of org.drools.core.common.RightTupleSets

    }

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

        boolean stagedDeleteWasEmpty = false;
        if ( isStreamMode() ) {
            stagedDeleteWasEmpty = memory.getSegmentMemory().getTupleQueue().isEmpty();
            memory.getSegmentMemory().getTupleQueue().add(new RightTupleEntry(rightTuple, rightTuple.getPropagationContext(), memory ));
            if ( log.isTraceEnabled() ) {
                log.trace( "JoinNode delete queue={} size={} pctx={} lt={}", System.identityHashCode( memory.getSegmentMemory().getTupleQueue() ), memory.getSegmentMemory().getTupleQueue().size(), PropagationContextImpl.intEnumToString(rightTuple.getPropagationContext()), rightTuple );
            }
        } else {
            stagedDeleteWasEmpty = stagedRightTuples.addDelete( rightTuple );
        }

        if ( memory.getAndDecCounter() == 1 ) {
            memory.linkNode( wm );
        } else if ( stagedDeleteWasEmpty ) {
View Full Code Here

Examples of org.drools.core.common.RightTupleSets

                                  final PropagationContext context,
                                  final InternalWorkingMemory workingMemory) {
        final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
        rightTuple.setPropagationContext( context );
        if ( isUnlinkingEnabled() ) {
            RightTupleSets stagedRightTuples = memory.getStagedRightTuples();
            boolean  stagedDeleteWasEmpty = false;
            if ( streamMode ) {
                stagedDeleteWasEmpty = memory.getSegmentMemory().getTupleQueue().isEmpty();
                memory.getSegmentMemory().getTupleQueue().add(new RightTupleEntry(rightTuple, context, memory ));
                //log.trace( "NotNode delete queue={} size={} lt={}", System.identityHashCode( memory.getSegmentMemory().getTupleQueue() ), memory.getSegmentMemory().getTupleQueue().size(), rightTuple );
            } else {
                stagedDeleteWasEmpty = stagedRightTuples.addDelete( rightTuple );
            }
           
            if memory.getAndDecCounter() == 1 && isEmptyBetaConstraints()  ) {
                // NotNodes can only be unlinked, if they have no variable constraints
                memory.linkNode( workingMemory );
View Full Code Here

Examples of org.drools.core.common.RightTupleSets

                      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

Examples of org.drools.core.common.RightTupleSets

    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

Examples of org.drools.core.common.RightTupleSets

   

    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

Examples of org.drools.core.common.RightTupleSets

    }  
   
    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

Examples of org.drools.core.common.RightTupleSets

        for (LeftTuple leftTuple = srcTuples.getDeleteFirst(); leftTuple != null; ) {
            LeftTuple next = leftTuple.getStagedNext();

            RightTuple rightTuple = (RightTuple) leftTuple.getObject();
            RightTupleSets rightTuples = bm.getStagedRightTuples();
            switch (rightTuple.getStagedType()) {
                case LeftTuple.INSERT: {
                    rightTuples.removeInsert(rightTuple);
                    break;
                }
                case LeftTuple.UPDATE: {
                    rightTuples.removeUpdate(rightTuple);
                    break;
                }
            }
            rightTuples.addDelete(rightTuple);

            if (bns != null) {
                // Add peered RightTuples, they are attached to FH - unlink LeftTuples that has a peer ref
                for (int i = 0; i < length; i++) {
                    rightTuple = rightTuple.getHandleNext();
                    rightTuples = bms[i].getStagedRightTuples();
                    switch (rightTuple.getStagedType()) {
                        case LeftTuple.INSERT: {
                            rightTuples.removeInsert(rightTuple);
                            break;
                        }
                        case LeftTuple.UPDATE: {
                            rightTuples.removeUpdate(rightTuple);
                            break;
                        }
                    }
                    rightTuples.addDelete(rightTuple);
                }
            }

            leftTuple.clearStaged();
            leftTuple = next;
        }

        for (LeftTuple leftTuple = srcTuples.getUpdateFirst(); leftTuple != null; ) {
            LeftTuple next = leftTuple.getStagedNext();

            RightTuple rightTuple = (RightTuple) leftTuple.getObject();
            RightTupleSets rightTuples = bm.getStagedRightTuples();
            switch (rightTuple.getStagedType()) {
                case LeftTuple.INSERT: {
                    rightTuples.removeInsert(rightTuple);
                    break;
                }
                case LeftTuple.UPDATE: {
                    rightTuples.removeUpdate(rightTuple);
                    break;
                }
            }
            rightTuples.addUpdate(rightTuple);

            if (bns != null) {
                // Add peered RightTuples, they are attached to FH - unlink LeftTuples that has a peer ref
                for (int i = 0; i < length; i++) {
                    rightTuple = rightTuple.getHandleNext();
                    rightTuples = bms[i].getStagedRightTuples();
                    switch (rightTuple.getStagedType()) {
                        case LeftTuple.INSERT: {
                            rightTuples.removeInsert(rightTuple);
                            break;
                        }
                        case LeftTuple.UPDATE: {
                            rightTuples.removeUpdate(rightTuple);
                            break;
                        }
                    }
                    rightTuples.addUpdate(rightTuple);
                }
            }

            leftTuple.clearStaged();
            leftTuple = next;
View Full Code Here

Examples of org.drools.core.common.RightTupleSets

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

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

            if (srcRightTuples.getDeleteFirst() != null) {
                doRightDeletes(existsNode, bm, wm, srcRightTuples, 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

Examples of org.drools.core.common.RightTupleSets

                           InternalWorkingMemory wm,
                           LeftTupleSets srcLeftTuples,
                           LeftTupleSets trgLeftTuples,
                           LeftTupleSets stagedLeftTuples) {
            boolean useLeftMemory = true;
            RightTupleSets srcRightTuples = am.getBetaMemory().getStagedRightTuples();

            // order of left and right operations is to minimise wasted of innefficient joins.

            // 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
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.