private void initTransient() { EntryPointNode epn = this.ruleBase.getRete().getEntryPointNode( EntryPoint.DEFAULT ); this.defaultEntryPoint = new NamedEntryPoint( EntryPoint.DEFAULT, epn, this ); this.entryPoints = new ConcurrentHashMap<String, WorkingMemoryEntryPoint>(); this.entryPoints.put( "DEFAULT", this.defaultEntryPoint ); updateEntryPointsCache(); }
isEvent ) ); this.concreteObjectTypeNode = ruleBase.getRete().getObjectTypeNodes( entryPoint ).get( objectType ); if ( this.concreteObjectTypeNode == null ) { BuildContext context = new BuildContext( ruleBase, ruleBase.getRete().getRuleBase().getReteooBuilder().getIdGenerator() ); context.setCurrentEntryPoint( entryPoint ); if ( DroolsQuery.class == clazz ) {
private static void buildNodeMap(InternalRuleBase ruleBase, Map<Integer, BaseNode> nodes) { for ( ObjectTypeNode sink : ruleBase.getRete().getObjectTypeNodes() ) { nodes.put( sink.getId(), sink ); addObjectSink( ruleBase, sink, nodes ); } }
EntryPointNode defaultEPNode = context.ruleBase.getRete().getEntryPointNode( EntryPoint.DEFAULT ); BuildContext buildContext = new BuildContext( context.ruleBase, context.ruleBase.getReteooBuilder().getIdGenerator() );
private ObjectTypeNode[] getMatchingObjectTypes(final Class<?> clazz) throws FactException { final List<ObjectTypeNode> cache = new ArrayList<ObjectTypeNode>(); for ( ObjectTypeNode node : ruleBase.getRete().getObjectTypeNodes( this.entryPoint ).values() ) { if ( clazz == DroolsQuery.class ) { // for query objects only add direct matches if ( ((ClassObjectType)node.getObjectType()).getClassType() == clazz ) { cache.add( node ); } } else if ( node.isAssignableFrom( new ClassObjectType( clazz ) ) ) { cache.add( node ); } } Collections.sort(cache, OBJECT_TYPE_NODE_COMPARATOR); return cache.toArray( new ObjectTypeNode[cache.size()] ); }
public static void writeInitialFactHandleRightTuples(MarshallerWriteContext context) throws IOException { ObjectOutputStream stream = context.stream; InternalRuleBase ruleBase = context.ruleBase; ObjectTypeNode initialFactNode = ruleBase.getRete().getEntryPointNode( EntryPoint.DEFAULT ).getObjectTypeNodes().get( ClassObjectType.InitialFact_ObjectType ); // do we write the fact to the objecttypenode memory if ( initialFactNode != null ) { ObjectHashSet initialFactMemory = (ObjectHashSet) context.wm.getNodeMemory( initialFactNode ); if ( initialFactMemory != null && !initialFactMemory.isEmpty() ) { //context.out.println( "InitialFactMemory true int:" + initialFactNode.getId() ); stream.writeBoolean( true ); stream.writeInt( initialFactNode.getId() ); //context.out.println( "InitialFact RightTuples" ); writeRightTuples( context.wm.getInitialFactHandle(), context ); } else { //context.out.println( "InitialFactMemory false " ); stream.writeBoolean( false ); } } else { //context.out.println( "InitialFactMemory false " ); stream.writeBoolean( false ); } }
public void build(BuildContext context, BuildUtils utils, RuleConditionElement rce) { final EntryPoint entry = (EntryPoint) rce; context.setCurrentEntryPoint( entry ); EntryPointNode epn = context.getRuleBase().getRete().getEntryPointNode( entry ); if( epn == null ) { context.setObjectSource( (ObjectSource) utils.attachNode( context, new EntryPointNode( context.getNextId(), context.getRuleBase().getRete(), context ) ) ); } else { context.setObjectSource( epn ); } }
public FactTemplateTypeConf(final EntryPoint entryPoint, final FactTemplate factTemplate, final InternalRuleBase ruleBase) { this.factTemplate = factTemplate; this.entryPoint = entryPoint; ObjectType objectType = new FactTemplateObjectType( factTemplate ); this.concreteObjectTypeNode = (ObjectTypeNode) ruleBase.getRete().getObjectTypeNodes( entryPoint ).get( objectType ); if ( this.concreteObjectTypeNode == null ) { BuildContext context = new BuildContext( ruleBase, ((ReteooRuleBase) ruleBase.getRete().getRuleBase()).getReteooBuilder().getIdGenerator() ); if ( context.getRuleBase().getConfiguration().isSequential() ) { // We are in sequential mode, so no nodes should have memory context.setTupleMemoryEnabled( false ); context.setObjectTypeNodeMemoryEnabled( false ); } else { context.setTupleMemoryEnabled( true ); context.setObjectTypeNodeMemoryEnabled( true ); } // there must exist an ObjectTypeNode for this concrete class this.concreteObjectTypeNode = PatternBuilder.attachObjectTypeNode( context, objectType ); } this.cache = new ObjectTypeNode[]{this.concreteObjectTypeNode}; }
final Rete source = this.ruleBase.getRete(); final ClassObjectType cot = new ClassObjectType( object.getClass() ); final Map<ObjectType, ObjectTypeNode> map = source.getObjectTypeNodes( EntryPoint.DEFAULT );
if ( candidate instanceof EntryPointNode ) { node = context.getRuleBase().getRete().getEntryPointNode( ((EntryPointNode) candidate).getEntryPoint() ); Map<ObjectType, ObjectTypeNode> map = context.getRuleBase().getRete().getObjectTypeNodes( context.getCurrentEntryPoint() ); if ( map != null ) { ObjectTypeNode otn = map.get( ((ObjectTypeNode) candidate).getObjectType() );