[rules-users] Accessing collections in conditional statements (inside/outside working memory)

Edson Tirelli tirelli at post.com
Mon Jun 21 10:58:21 EDT 2010


    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 at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100621/2c4726d2/attachment.html 


More information about the rules-users mailing list