Flink: using multiple aggregates in a window stream

I have data coming in as id, float, float, float. I want min (), max () and sum () to order the fields and group them by id value.

Using flatMap I have Tuple4 with bits, but I'm not sure how to send it to the next step.

What I have:

dataStream.flatMap(new mapper()).keyBy(0) .timeWindowAll(Time.of(5, TimeUnit.SECONDS)).min(1) .timeWindowAll(Time.of(5, TimeUnit.SECONDS)).sum(2) .timeWindowAll(Time.of(5, TimeUnit.SECONDS)).sum(3) .map(new printstuff()); 

Is this the right way to handle this? Or do I need to put each timeWindowAll in my own statement using keyBy etc.?

+5
source share
1 answer

A chain of several aggregation functions is not yet supported in the DataStream API.

In your example, you create three different 5-second windows, each of which uses a single aggregation. This is probably not what you want to do. I would execute a custom ReduceFunction that executes all clusters at once in one window. See “Window Reduction” in the DataStream Documentation for an example.

+5
source

Source: https://habr.com/ru/post/1235052/


All Articles