@@ -0,0 +1,2447 @@
+/*%0A * Copyright 2005 JBoss Inc%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.drools.core.reteoo;%0A%0Aimport org.drools.core.common.BaseNode;%0Aimport org.drools.core.common.InternalWorkingMemory;%0Aimport org.drools.core.common.Memory;%0Aimport org.drools.core.common.MemoryFactory;%0Aimport org.drools.core.impl.InternalKnowledgeBase;%0Aimport org.kie.api.KieBase;%0A%0Apublic class SegmentMemoryInitializer %7B%0A%0A    public static void createAllSegmentPrototypes(KieBase kieBase) %7B%0A        InternalWorkingMemory wm = ( InternalWorkingMemory ) kieBase.newKieSession();%0A        Rete rete = (( InternalKnowledgeBase ) kieBase).getRete();%0A        for (EntryPointNode entryPointNode : rete.getEntryPointNodes().values()) %7B%0A            visitNode( wm, entryPointNode );%0A        %7D%0A    %7D%0A%0A    private static void visitNode(InternalWorkingMemory wm, BaseNode node) %7B%0A        Sink%5B%5D sinks = node.getSinks();%0A        if (sinks != null) %7B%0A            for (Sink sink : sinks) %7B%0A                if ( sink instanceof LeftInputAdapterNode ) %7B%0A                    visitSegmentRoot(wm, (LeftInputAdapterNode) sink);%0A                %7D else if ( NodeTypeEnums.isBetaNode(sink) ) %7B%0A                    continue;%0A                %7D else if ( sink instanceof BaseNode ) %7B%0A                    visitNode(wm, (BaseNode) sink);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    private static void visitSegmentRoot( InternalWorkingMemory wm, LeftTupleSource rootNode) %7B%0A        Memory nodeMem = wm.getNodeMemory( (MemoryFactory) rootNode );%0A        SegmentMemory smem = nodeMem.getOrCreateSegmentMemory( rootNode, wm );%0A        BaseNode tipNode = (BaseNode) smem.getTipNode();%0A%0A        Sink%5B%5D sinks = tipNode.getSinks();%0A        if (sinks != null) %7B%0A            for (Sink sink : sinks) %7B%0A                if ( sink instanceof LeftTupleSource ) %7B%0A                    visitSegmentRoot(wm, (LeftTupleSource) sink);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

allow to eagerly create segment prototypes