[rules-users] one question about asserting facts

Anstis, Michael (M.) manstis1 at ford.com
Fri Feb 6 04:46:16 EST 2009


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




More information about the rules-users mailing list