OK, sorry, I missed that (important) part ;-)
Reading the API Docs says execute "Insert a List of facts, an fire the rules,
returning when finished. This will assert the list of facts as SEPARATE facts to the
engine (NOT as a List)".
So I guess "r1" will activate for ALL facts in "allFacts" but whether
the pattern in r1 ("from") leads to duplicate activations of the same objects
obtained from the global I don't know. Section "2.5.8. Truth Maintenance with
Logical Objects" of the manual talks about STATED facts and a check for equivalence
but I think this only applies to insertions into WM. I'd guess that you'd get two
activations for those facts in list1 and allFacts because of the use of "from" -
but it would be a guess. Have you conducted a test (if so what did you get) or is it
hyperthetical at the moment?
Sorry my eager response turned out not to be that helpful after all!
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Yoni Mazar
Sent: 30 July 2008 10:15
To: rules-users(a)lists.jboss.org
Subject: RE: [rules-users] 'from global' and the workingMemory
Thanks for the prompt response.
In the example bellow one can see that list1 items are actually passed to
the execute() method. Hence the dilema whether the engine will look at the
WM or at the global. to my understanding, it will loop on the global. I just
want to be sure that I understand it correctly.
Thanks, Yoni
Anstis, Michael (M.) wrote:
I believe the "from" keyword will iterate only the items in list1.
I don't consider it naïve though; just doing what it is documented to do.
If you want to iterate facts in the RETE network you need to insert them
into working memory.
You could use a rule to do this (copy from a global into WM) or do it from
your application.
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Yoni Mazar
Sent: 30 July 2008 09:46
To: rules-users(a)lists.jboss.org
Subject: [rules-users] 'from global' and the workingMemory
Hi all,
Let's look at the following example:
****DRL file***************
global java.util.List list1;
global java.util.List list2;
rule "r1" when Fact(...) from list1 then ....
****Application************
List<Fact> facts1 = ...
List<Fact> facts2 = ...
List<Fact> allFacts= facts1+facts2
StatelessSession session = ...
session.setGlobal("list1", facts1);
session.setGlobal("list2", facts2);
session.execute(allFacts)
The question: will rule "r1" use the facts from the working memory and a
rete algorithm, or will it naively loop on list1 items?
BTW, can we use generic in the DRL section? for example:
global java.util.List<Fact> list1;
Thanks for the help, Yoni
--
View this message in context:
http://www.nabble.com/%27from-global%27-and-the-workingMemory-tp18728639p...
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
View this message in context:
http://www.nabble.com/%27from-global%27-and-the-workingMemory-tp18728639p...
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users