Flink: Trigger.onElement working

1k views Asked by At

I am doing functions on a datastream,

DataStream<Tuple4<String,String,Double,Double>> price_warning=datastream_in .flatMap(new Splitter())// transformation flatmap .keyBy(2) .window(SlidingProcessingTimeWindows.of(Time.seconds(180),Time.seconds(10))) .trigger(new ElementTimeTrigger()) .apply(new WindowFunction());

This is a part of my code, just for the idea that what I am doing. Here, on datastream, I am doing flatmap to parse the datastream_in into Tuple, then the stream is keyby on second filed of tuple. After that I apply sliding window followed by trigger. Here I am using onElement() method for triggering. Finally, I use apply as a custom function.

When I run the code, the apply function is called 18 times (180/10, ref. sliding window) for each message that I have parsed. What can be the reason behind it? How the trigger exactly work with sliding window?

** I can also provide the entire code if necessary.

1

There are 1 answers

1
Dawid Wysakowicz On

Trigger tells where a window should be emitted. In your case if I understand you correctly You trigger window emitting for every element that enters your stream thus the number 18. The SlidingProcessingTimeWindow have already a default trigger that will emit windows when the processing time pass the end of window.

For more info on Trigger concept you can read this