Search in sources :

Example 1 with ReteooBuilder

use of org.drools.core.reteoo.ReteooBuilder in project drools by kiegroup.

the class KnowledgeBaseImpl method setupRete.

protected void setupRete() {
    this.rete = new Rete(this);
    this.reteooBuilder = new ReteooBuilder(this);
    NodeFactory nodeFactory = kieComponentFactory.getNodeFactoryService();
    // always add the default entry point
    EntryPointNode epn = nodeFactory.buildEntryPointNode(this.reteooBuilder.getIdGenerator().getNextId(), RuleBasePartitionId.MAIN_PARTITION, this.getConfiguration().isMultithreadEvaluation(), this.rete, EntryPointId.DEFAULT);
    epn.attach();
    BuildContext context = new BuildContext(this);
    context.setCurrentEntryPoint(epn.getEntryPoint());
    context.setTupleMemoryEnabled(true);
    context.setObjectTypeNodeMemoryEnabled(true);
    context.setPartitionId(RuleBasePartitionId.MAIN_PARTITION);
    ObjectTypeNode otn = nodeFactory.buildObjectTypeNode(this.reteooBuilder.getIdGenerator().getNextId(), epn, ClassObjectType.InitialFact_ObjectType, context);
    otn.attach(context);
}
Also used : EntryPointNode(org.drools.core.reteoo.EntryPointNode) Rete(org.drools.core.reteoo.Rete) ReteooBuilder(org.drools.core.reteoo.ReteooBuilder) NodeFactory(org.drools.core.reteoo.builder.NodeFactory) BuildContext(org.drools.core.reteoo.builder.BuildContext) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode)

Example 2 with ReteooBuilder

use of org.drools.core.reteoo.ReteooBuilder in project drools by kiegroup.

the class ReteooBuilderPerformanceTest method addRules.

private static void addRules(InternalKnowledgePackage pkg) {
    ReteooBuilder[] reteBuilders = getReteBuilders(RETEBUILDER_COUNT);
    System.out.println("Adding rules to ReteBuilder");
    long start = System.currentTimeMillis();
    for (ReteooBuilder reteBuilder : reteBuilders) {
        for (Rule rule : pkg.getRules()) reteBuilder.addRule((RuleImpl) rule);
    }
    System.out.println("Added " + RULE_COUNT + " rules to each ReteBuilder's in " + format(System.currentTimeMillis() - start));
}
Also used : ReteooBuilder(org.drools.core.reteoo.ReteooBuilder) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl) Rule(org.kie.api.definition.rule.Rule)

Example 3 with ReteooBuilder

use of org.drools.core.reteoo.ReteooBuilder in project drools by kiegroup.

the class ReteooBuilderPerformanceTest method getReteBuilders.

private static ReteooBuilder[] getReteBuilders(int count) {
    System.out.println("Creating " + count + " ReteBuilder's");
    ReteooBuilder[] reteBuilders = new ReteooBuilder[count];
    RuleBaseConfiguration conf = new RuleBaseConfiguration();
    for (int i = 0; i < reteBuilders.length; i++) {
        reteBuilders[i] = new ReteooBuilder(new KnowledgeBaseImpl("id1", conf));
    }
    return reteBuilders;
}
Also used : RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) ReteooBuilder(org.drools.core.reteoo.ReteooBuilder) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl)

Aggregations

ReteooBuilder (org.drools.core.reteoo.ReteooBuilder)3 RuleBaseConfiguration (org.drools.core.RuleBaseConfiguration)1 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)1 KnowledgeBaseImpl (org.drools.core.impl.KnowledgeBaseImpl)1 EntryPointNode (org.drools.core.reteoo.EntryPointNode)1 ObjectTypeNode (org.drools.core.reteoo.ObjectTypeNode)1 Rete (org.drools.core.reteoo.Rete)1 BuildContext (org.drools.core.reteoo.builder.BuildContext)1 NodeFactory (org.drools.core.reteoo.builder.NodeFactory)1 Rule (org.kie.api.definition.rule.Rule)1