[rules-users] correlating two collects

Edson Tirelli tirelli at post.com
Thu Aug 2 10:29:05 EDT 2007


    Yury,

    Correlation can happen in many ways, but I would say your general
approach is correct. Answering your questions:

1. Both collect and accumulate work (as it is today) on single patterns.
This means whenever you are using collect, you could be using accumulate.
Just have in mind that accumulate is more powerful and flexible that
collect, but it is also heavier. So, if collect does what you need, go with
collect, otherwise fall back to accumulate.

3. Collect is incremental (on 4.0 GA) for all working memory operations:
insert/update/retract. Accumulate is always incremental for insert, but for
modify and retract it is incremental only if you provide the "reverse"
action in case you are using adhoc operations. If you are using accumulate
functions, modify and retract are incremental if the function supports
reverse calculation.

    []s
    Edson

2007/8/1, Yuri de Wit <ydewit at gmail.com>:
>
> I am finally having some time to use collects. What I basically need
> to do is to collect items from a list using a specific criteria, then
> collect items from a diff list using another criteria, and finally
> compare the groups collected using a 3rd criteria
>
> Here is what I am thinking:
>
> i : Item(type==A)
> ig : ItemGroup(size>1)
>          collect Item(a==i.a, b==i.b, ... n==i.n)
>
> i2: Item(type==B)
> ig2 : ItemGroup( size>1,
>                          ga==ig.ga, gb==i.gb, .... )
>          collect Item(a==i.a, b==i.b, ... n==i.n)
>
> 1) It is quite nice that any implementation of java.util.Collection
> can be the resut of collect. ItemGroup here not only keeps hold of all
> Items returned but has some aggregate properties (afaik, I cannot use
> the aggregate functions with accumulate since I have multiple column
> aggregation).
>
> 2) Am I on the right track? Or is there a better way?
>
> 3) Is the collect recomputed from scratch or incrementally every time
> a new fact is asserted or updated?
>
> thanks
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070802/ac09b893/attachment.html 


More information about the rules-users mailing list