我的输入流
type=1, time=10, start=123, other params
type=2, time=11, start=123, other params
type=2, time=12, start=123, other params
type=1, time=13, start=235, other params
type=2, time=14, start=123, other params
type=2, time=15, start=235, other params
type=2, time=16, start=235, other params
type=1, time=17, start=456, other params
...
我想创建一个以 type=1 事件开头的窗口。之后,我不断有 type=2 事件,直到 key start=123 停止。
type=1 事件类似于 start-event,type=2 事件类似于 ping 事件,表示生产者还活着。我将它们放在 2 个不同的主题中。
我有一个关于创建自定义会话窗口的想法,该窗口在 type=1 事件发生时启动,该窗口一直打开,直到距离最后一个 type=2 事件超过 3 分钟。
stream
.keyBy(start)
.window(CustomWindow())
.trigger(CustomTrigger())
...
但是,我不知道如何创建仅在接收事件类型 = 1 时启动的自定义窗口。我阅读了有关触发器的内容,它是关于何时触发窗口函数,而不是何时创建窗口。
预期结果:
type=event-end, start=123, duration=3 (because there are 3 type=2 log for 123)
-> this fires at time=17 because last ping event is at time=14, there is a gap of 3.
type=event-end, start=235, duration=2 (because there are 3 type=2 log for 123)
-> this fires at time=19 because last ping event is at time=16, there is a gap of 3 and if there is no more ping after time=16.
如何在 Flink 中实现这个自定义窗口?