Re: [rules-users] one question about asserting facts

2009-02-06 Thread Edson Tirelli
   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.) 

> 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-boun...@lists.jboss.org
> [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Senlin Liang
> Sent: 05 February 2009 20:06
> To: rules-users@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@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> ___
> rules-users mailing list
> rules-users@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
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] one question about asserting facts

2009-02-06 Thread Anstis, Michael (M.)
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-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Senlin Liang
Sent: 05 February 2009 20:06
To: rules-users@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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users