Package org.drools.core.reteoo.AccumulateNode

Examples of org.drools.core.reteoo.AccumulateNode.AccumulateContext


            ContextEntry[] contextEntry = bm.getContext();
            BetaConstraints constraints = accNode.getRawConstraints();

            for (LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; ) {
                LeftTuple next = leftTuple.getStagedNext();
                final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();

                PropagationContext context = leftTuple.getPropagationContext();

                constraints.updateFromTuple(contextEntry,
                                            wm,
View Full Code Here


                    if (constraints.isAllowedCachedRight(bm.getContext(),
                                                         leftTuple)) {
                        if (leftTuple.getStagedType() == LeftTuple.NONE) {
                            trgLeftTuples.addUpdate(leftTuple);
                        }
                        final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
                        // add a new match
                        addMatch(accNode,
                                 accumulate,
                                 leftTuple,
                                 rightTuple,
                                 null,
                                 null,
                                 wm,
                                 am,
                                 accctx,
                                 true);
                    }
                }
            } else {
                // in the same bucket, so iterate and compare
                for (; leftTuple != null; leftTuple = (LeftTuple) leftIt.next(leftTuple)) {
                    if (constraints.isAllowedCachedRight(bm.getContext(),
                                                         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                           
                            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,
                                    childLeftTuple,
View Full Code Here

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


                    final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
                    leftTuple.setObject(null);

                    removePreviousMatchesForLeftTuple(accNode,
                                                      accumulate,
                                                      leftTuple,
View Full Code Here

                        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);
                            }
View Full Code Here

                                                              final LeftTupleSets trgLeftTuples) {
            for (LeftTuple match = firstChild; match != null; ) {
                final LeftTuple next = match.getRightParentNext();

                final LeftTuple leftTuple = match.getLeftParent();
                final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
                removeMatch(accNode,
                            accumulate,
                            rightTuple,
                            match,
                            workingMemory,
View Full Code Here

        public ProtobufMessages.ActionQueue.Action serialize(MarshallerWriteContext context) {
            throw new UnsupportedOperationException( "Should not be present in network on serialisation" );
        }

        public void execute(InternalWorkingMemory workingMemory) {
            final AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
            accctx.setAction( null );
            node.evaluateResultConstraints( source,
                                            leftTuple,
                                            context,
                                            workingMemory,
                                            memory,
View Full Code Here

            case NodeTypeEnums.AccumulateNode: {
                // accumulate nodes generate new facts on-demand and need special procedures when de-serializing from persistent storage
                AccumulateMemory memory = (AccumulateMemory) context.wm.getNodeMemory( (BetaNode) sink );
                memory.betaMemory.getLeftTupleMemory().add( parentLeftTuple );

                AccumulateContext accctx = new AccumulateContext();
                parentLeftTuple.setObject( accctx );

                // first we de-serialize the generated fact handle
                InternalFactHandle handle = readFactHandle( context );
                accctx.result = new RightTuple( handle,
View Full Code Here

            }
            case NodeTypeEnums.AccumulateNode : {
                //context.out.println( ".... AccumulateNode" );
                // accumulate nodes generate new facts on-demand and need special procedures when serializing to persistent storage
                AccumulateMemory memory = (AccumulateMemory) context.wm.getNodeMemory( (BetaNode) sink );
                AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
                // first we serialize the generated fact handle
                writeFactHandle( context,
                                 stream,
                                 context.objectMarshallingStrategyStore,
                                 accctx.result.getFactHandle() );
View Full Code Here

        if ( accmem.betaMemory.getLeftTupleMemory().size() > 0 ) {
            ProtobufMessages.NodeMemory.AccumulateNodeMemory.Builder _accumulate = ProtobufMessages.NodeMemory.AccumulateNodeMemory.newBuilder();

            final org.drools.core.util.Iterator tupleIter = accmem.betaMemory.getLeftTupleMemory().iterator();
            for ( LeftTuple leftTuple = (LeftTuple) tupleIter.next(); leftTuple != null; leftTuple = (LeftTuple) tupleIter.next() ) {
                AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
                if ( accctx.getResultFactHandle() != null ) {
                    FactHandle _handle = ProtobufMessages.FactHandle.newBuilder()
                            .setId( accctx.getResultFactHandle().getId() )
                            .setRecency( accctx.getResultFactHandle().getRecency() )
                            .build();
                    _accumulate.addContext(
                            ProtobufMessages.NodeMemory.AccumulateNodeMemory.AccumulateContext.newBuilder()
                                    .setTuple( PersisterHelper.createTuple( leftTuple ) )
                                    .setResultHandle( _handle )
View Full Code Here

                    AccumulateMemory am = (AccumulateMemory) memory;
                    bm = am.getBetaMemory();
                    FastIterator it = bm.getLeftTupleMemory().fullFastIterator();
                    LeftTuple lt = ((BetaNode) node).getFirstLeftTuple(bm.getLeftTupleMemory(), it);
                    for (; lt != null; lt = (LeftTuple) it.next(lt)) {
                        AccumulateContext accctx = (AccumulateContext) lt.getObject();
                        followPeer(accctx.getResultLeftTuple(), smem, sinks,  sinks.size()-1, insert, wm);
                    }
                } else if ( NodeTypeEnums.ExistsNode == node.getType() ) {
                    bm = (BetaMemory) wm.getNodeMemory((MemoryFactory) node);
                    FastIterator it = bm.getRightTupleMemory().fullFastIterator(); // done off the RightTupleMemory, as exists only have unblocked tuples on the left side
                    RightTuple rt = ((BetaNode) node).getFirstRightTuple(bm.getRightTupleMemory(), it);
View Full Code Here

TOP

Related Classes of org.drools.core.reteoo.AccumulateNode.AccumulateContext

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.