If you have only one or two rules using "from $collection", you are probably ok. If you have more, the "from" will probably be much heavier than inserting facts into the working memory (assuming not all of your "from" conditions will be shared among rules) by the reasons stated by Thomas, even if you are not modifying facts.

    Also, remember you can negate operators:

Parent( collection contains $child )

Parent( collection not contains $child )

    That is more efficient than composing "exists"/"not" and "from".

    Edson


2010/6/21 Evert Penninckx <evert.penninckx@gmail.com>

Thanks for the info, Thomas.

Currently, I'm not modifying the children. Yet :) For now my rules are only
deriving, I hope I can keep it this way, but we'll see.

Good point about the exists. Many of my rules have indeed as condition the
existence of "a" child. But, in many cases I use some bindings which are
referred to in another condition or consequence, like
rule "01"
when
   $child : Child($attribute : attribute)
   $parent : Parent(children contains $child)
then
  // do stuff
end
To use the exists clause I rewrote them to
rule "02"
when
  $parent : Parent()
  exists( Child() from $parent.children )
then
  // do stuff
end
However, in rule 02 I loose the binding for $attribute.  I'll have to get it
from another, probably more adequate, fact.



Greetz

Evert


--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Accessing-collections-in-conditional-statements-inside-outside-working-memory-tp905005p911205.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com