This may work.
myStream.groupBy(new Fields("user"))
.persistentAggregate(new MemoryMapState.Factory(),
new Fields("some_int_1"),
new Sum(),
new Fields("total_some_int_1")
.newValuesStream()
.persistentAggregate(new MemoryMapState.Factory(),
new Fields("some_int_2"),
new Sum(),
new Fields("total_some_int_2");
You could also create your own Function to combine 1 and 2 into a single
object and implement your own CombinerAggregator for it. This is how you
could do it with only one aggregate step and it also lets your store the
values together.
On Wed, Jul 9, 2014 at 7:38 AM, c_inconnu <[email protected]> wrote:
> Hi,
>
> I'm new to trident and I'm trying to solve the following use case. I've
> read several times the documentation and I've been quite deep in the code
> base but couldn't figure out how to do it...
>
> My input tuples have the keys (user, some_int_1, some_int_2).
> My output should be the sum of some_int_1 and the sum of some_int_2 (two
> fields, not one) by user, ie. (user, total_some_int_1, total_some_int_2).
>
> I've tried something like that:
>
> myStream.groupBy(new Fields("user"))
> .persistentAggregate(new MemoryMapState.Factory(),
> new Fields("some_int_1", "some_int_2"),
> new Sum(),
> new Fields("total_some_int_1", "total_
> some_int_2"))
>
> but got
>
> Exception in thread "main" java.lang.IllegalArgumentException: Combiner
> aggs only take a single field as input. Got this instead: [
> total_some_int_1, total_some_int_2]
>
> what is the correct way of doing this ?
> thanks
>
>