Package org.drools.core.common

Examples of org.drools.core.common.Memory


                    LeftTupleSource subnetworkLts = riaNode.getLeftTupleSource();
                    while ( subnetworkLts.getLeftTupleSource() != riaNode.getStartTupleSource()) {
                        subnetworkLts = subnetworkLts.getLeftTupleSource();
                    }

                    Memory rootSubNetwokrMem = wm.getNodeMemory( (MemoryFactorysubnetworkLts);
                    SegmentMemory subNetworkSegmentMemory = rootSubNetwokrMem.getSegmentMemory();
                    if ( subNetworkSegmentMemory == null ) {
                        // we need to stop recursion here
                        createSegmentMemory( ( LeftTupleSource ) subnetworkLts, wm );
                    }
View Full Code Here


    public static void createChildSegments(final InternalWorkingMemory wm,
                                            SegmentMemory smem,
                                            LeftTupleSinkPropagator sinkProp) {
        for ( LeftTupleSinkNode sink = ( LeftTupleSinkNode ) sinkProp.getFirstLeftTupleSink(); sink != null; sink = sink.getNextLeftTupleSinkNode() ) {
            Memory memory = wm.getNodeMemory( (MemoryFactory ) sink );

             if ( !( NodeTypeEnums.isTerminalNode( sink  ) || sink.getType() == NodeTypeEnums.RightInputAdaterNode ) ) {
                if ( memory.getSegmentMemory() == null ) {
                    SegmentUtilities.createSegmentMemory( (LeftTupleSource ) sink, wm );
                }
            } else {
                // RTNS and RiaNode's have their own segment, if they are the child of a split.
                if ( memory.getSegmentMemory() == null ) {
                    SegmentMemory childSmem = new SegmentMemory(sink);
                    PathMemory rmem;
                    if ( NodeTypeEnums.isTerminalNode( sink  ) ) {
                        rmem = (PathMemory) memory;
                    } else {
                        rmem =  ((RiaNodeMemory) memory ).getRiaPathMemory();
                    }
                    rmem.getSegmentMemories()[ rmem.getSegmentMemories().length -1 ] = childSmem;
                    rmem.setSegmentMemory( childSmem );
                    childSmem.getPathMemories().add( rmem );

                    childSmem.setTipNode( sink );
                    childSmem.setSinkFactory( sink );
                }
            }
            smem.add( memory.getSegmentMemory() );
        }
    }
View Full Code Here

        ((DefaultAgenda)ksession.getAgenda()).getGarbageCollector().forceGcUnlinkedRules();

        NodeMemories nm = ( (StatefulKnowledgeSessionImpl) ksession ).getNodeMemories();
        for ( int j = 0; j < nm.length(); j++ ) {
            Memory mem = nm.peekNodeMemory( j );
            if ( mem != null && mem instanceof PathMemory) {
                PathMemory pathMemory = (PathMemory) mem;
                StreamTupleEntryQueue kiu = pathMemory.getStreamQueue();
                System.out.println( kiu + " >> " + kiu.size() );
                assertEquals( 0, kiu.size() );
View Full Code Here

        try {
            List<String[]> cmds = step.getCommands();
            List<InternalFactHandle> handles = (List<InternalFactHandle>) context.get( "Handles" );

            BetaMemory bm;
            Memory childMemory = wm.getNodeMemory( node );
            if ( node.getType() == NodeTypeEnums.AccumulateNode ) {
                bm =  ((AccumulateMemory) childMemory).getBetaMemory();
            } else {
                bm =  (BetaMemory) childMemory;
            }
View Full Code Here

        ((DefaultAgenda)ksession.getAgenda()).getGarbageCollector().forceGcUnlinkedRules();

        NodeMemories nm = ( (StatefulKnowledgeSessionImpl) ksession ).getNodeMemories();
        for ( int j = 0; j < nm.length(); j++ ) {
            Memory mem = nm.peekNodeMemory( j );
            if ( mem != null && mem instanceof PathMemory) {
                PathMemory pathMemory = (PathMemory) mem;
                StreamTupleEntryQueue kiu = pathMemory.getStreamQueue();
                System.out.println( kiu + " >> " + kiu.size() );
                assertEquals( 0, kiu.size() );
View Full Code Here

                    tupleSource = (LeftTupleSource) sink;
                } else {
                    // rtn or rian
                    // While not technically in a segment, we want to be able to iterate easily from the last node memory to the ria/rtn memory
                    // we don't use createNodeMemory, as these may already have been created by, but not added, by the method updateRiaAndTerminalMemory
                    Memory memory = wm.getNodeMemory((MemoryFactory) sink);
                    if (sink.getType() == NodeTypeEnums.RightInputAdaterNode) {
                        PathMemory riaPmem = ((RiaNodeMemory)memory).getRiaPathMemory();
                        smem.getNodeMemories().add( riaPmem );

                        RightInputAdapterNode rian = ( RightInputAdapterNode ) sink;
                        ObjectSink[] nodes = rian.getSinkPropagator().getSinks();
                        for ( ObjectSink node : nodes ) {
                            if ( NodeTypeEnums.isLeftTupleSource(node) )  {
                                SegmentMemory parentSmem = createSegmentMemory( (LeftTupleSource) node, wm );
                            }
                        }
                    } else if (NodeTypeEnums.isTerminalNode(sink)) {
                        smem.getNodeMemories().add((PathMemory)memory);
                    }
                    memory.setSegmentMemory(smem);
                    smem.setTipNode(sink);
                    break;
                }
            } else {
                // not in same segment
View Full Code Here

            LeftTupleSource subnetworkLts = riaNode.getLeftTupleSource();
            while (subnetworkLts.getLeftTupleSource() != riaNode.getStartTupleSource()) {
                subnetworkLts = subnetworkLts.getLeftTupleSource();
            }

            Memory rootSubNetwokrMem = wm.getNodeMemory((MemoryFactory) subnetworkLts);
            SegmentMemory subNetworkSegmentMemory = rootSubNetwokrMem.getSegmentMemory();
            if (subNetworkSegmentMemory == null) {
                // we need to stop recursion here
                createSegmentMemory((LeftTupleSource) subnetworkLts, wm);
            }
View Full Code Here

                                                        LeftTupleSinkPropagator sinkProp) {
        if ( !smem.isEmpty() ) {
              return; // this can happen when multiple threads are trying to initialize the segment
        }
        for (LeftTupleSinkNode sink = (LeftTupleSinkNode) sinkProp.getFirstLeftTupleSink(); sink != null; sink = sink.getNextLeftTupleSinkNode()) {
            Memory memory = wm.getNodeMemory((MemoryFactory) sink);

            SegmentMemory childSmem = createChildSegment(wm, sink, memory);
            smem.add(childSmem);
        }
    }
View Full Code Here

        InternalWorkingMemory wm = context.wm;
        NodeMemories memories = wm.getNodeMemories();
        // only some of the node memories require special serialization handling
        // so we iterate over all of them and process only those that require it
        for ( int i = 0; i < memories.length(); i++ ) {
            Memory memory = memories.peekNodeMemory( i );
            // some nodes have no memory, so we need to check for nulls
            if ( memory != null ) {
                ProtobufMessages.NodeMemory _node = null;
                switch ( memory.getNodeType() ) {
                    case NodeTypeEnums.AccumulateNode : {
                        _node = writeAccumulateNodeMemory( i, memory );
                        break;
                    }
                    case NodeTypeEnums.RightInputAdaterNode : {
View Full Code Here

        RightInputAdapterNode riaNode = (RightInputAdapterNode) node;

        ObjectSink[] sinks = riaNode.getSinkPropagator().getSinks();
        BetaNode betaNode = (BetaNode) sinks[0];

        Memory betaMemory = memories.peekNodeMemory( betaNode.getId() );
        if ( betaMemory == null ) {
            return null;
        }
        BetaMemory bm;
        if ( betaNode.getType() == NodeTypeEnums.AccumulateNode ) {
View Full Code Here

TOP

Related Classes of org.drools.core.common.Memory

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.