0
votes

I need your advice, really In my task i need to aggregate events by two type of aggregation. First type - is onCount, second type - is onTime.

If event is for onCount aggregation - it has fields number - number of event, and totalCount - what count of events we should accumulate before aggregate.

If event is for onTime aggregation - it has field time - it's date after which we should get all accumulate events and start aggregating.

I can groupped events by type, start window and set trigger:

stream
.keyBy(e => (e.clientSystemId, e.onMode))
.window(GlobalWindows.create())
.trigger(new WindowAggregationTrigger())

But in trigger i need to have state - total count or time. And in best solution - i need two different triggers - first is about counting and second - is about time aggregation.

My question is - how beautifully to solve this problem? When i need two triggers with different logic - first about counting, second- about time trigger.

I do not ask to solve the problem for me, I ask for advice.

We developing on Apache Flink 1.4.

1

1 Answers

1
votes

It is not possible to apply two different triggers in the same window operator, but you can implement a single trigger to distinguish the onCount and onTime cases.

However, I would recommend to split the stream into two streams (using split() or side outputs), apply window operators with different triggers on the splitted streams, and later union() the streams together (if that is necessary).