Reputation: 7715
I have stream of events with their own timestamp. I need to divide this stream into 1 minute not overlapping windows and perform some calculations. I'm very new to Flink but figure out sth like this would work:
dataStream.keyBy(0).window(TumblingEventTimeWindows.of(Time.seconds(60)))
I'm not sure though how to achieve that window starts at the beginning of the minute and not at the moment of execution.
Maybe there are some better choises for that then Flink?
Upvotes: 0
Views: 525
Reputation: 18987
Tumbling time windows can be defined as follows:
val execEnv = StreamExecutionEnvironment.getExecutionEnvironment
execEnv.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)
val stream: DataStream[(String, Int)] = ???
val result = stream
.keyBy(0)
// define tumbling window of 1 min length
.timeWindow(Time.minutes(1))
// apply sum aggregation on window
.sum(1)
Flink aligns time windows on multiples of the window length starting at the Epoch time (1070-01-01 00:00:00
). So time windows of 1 minute will always be aligned to the start of a minute.
Upvotes: 1