Hi Edson,
A follow up question just came up:
I not only need to collect Items that share common properties
(grouping) but I also want to further filter the collect by selecting
only the ones that dont have a related fact.
Just to exemplify, here is what my rule would look like if I were
trying to group two Items:
i : Item()
not ItemEvent( item == i )
i2: Item( a == i.a, b == i.b, ... )
not ItemEvent( item == i2 )
Is that possible to use collect? It seems that I should resort to
accumulate, right?
thanks,
-- yuri
On 8/2/07, Edson Tirelli <tirelli(a)post.com> wrote:
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(a)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(a)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
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users