[rules-users] one question about asserting facts

Edson Tirelli tirelli at post.com
Fri Feb 6 08:44:09 EST 2009


   Mike is correct again. What makes fact insertion faster or slower is the
rules you have in your rulebase, because LHS patterns are evaluated at
insert time. Although, there are several optimizations (and the Rete
algorithm itself) that make this evaluation as light as possible. Usually,
you should not feel noticeable delays in fact insertion, but if you have
cross products in your rules, then you may have problems since they lead to
combinatorial explosions.

    So, take a look at your rules and ensure they are optimally written.

    []s
    Edson

2009/2/6 Anstis, Michael (M.) <manstis1 at ford.com>

> Hello,
>
> Unless the Drools team have a "secret optimisation" *I think* there is
> no other way to insert large numbers of facts.
>
> Think about it; every fact you insert will need to be propagated through
> the RETE network in order for the correct rules to be activated.
>
> You could however optimise your rules to ensure the facts are processed
> as efficiently as possible. For example if you are interested in
> DataClasses where "line" is not empty you should have the RHS pattern
> that checks for this before other RHS patterns in rules. This should
> ensure the fact is not propagated through the network further than is
> really necessary. I believe Drools does this itself when the RETE
> network is built by have specialised "Object" nodes that filter out
> classes you have not consumed in RHS patters (so if you insert a Foo
> class into WM and your rules only use Bar classes the Foo class does not
> propagate further).
>
> With kind regards,
>
> Mike
>
>
> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org
> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Senlin Liang
> Sent: 05 February 2009 20:06
> To: rules-users at lists.jboss.org
> Subject: [rules-users] one question about asserting facts
>
> Hi all,
>
> I am trying to assert (or insert) a large number of facts (or
> DataClass objects) in to a session, what i am doing right now is to
> insert them one by one as
> ---------------------
>           while (line != null) {
>               str = bufRead.readLine();
>               session.insert(new DataClass(line, str));
>               line = bufRead.readLine();
>           }
> ---------------------
>
> My question: is there an efficient way to insert all facts at once, so
> that it takes less time?
>
> Thanks,
> Senlin
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090206/58f8f147/attachment.html 


More information about the rules-users mailing list