Josh Lemer
Josh Lemer

Reputation: 446

Flink event-time session windows with max total time

I was wondering if it's possible to create a WindowAssigner that is similar to:

EventTimeSessionWindows.withGap(Time.seconds(1L))

Except I don't want the window to keep growing in event-time on each element. I want the beginning of the window to be defined at the first element received (for that key), and end exactly 1 second later, no matter how many elements arrive in that second.

So it would probably look like this hypothetically:

EventTimeSessionWindows.withMax(Time.seconds(1L))

Thanks!

Upvotes: 1

Views: 1098

Answers (1)

Fabian Hueske
Fabian Hueske

Reputation: 18987

There is no built-in window for this use case.

However, you can implement this with a GlobalWindow, which collects all incoming elements, and a Trigger that registers a timer when an element is received and the window is empty, i.e., the first element or the first element after the window was purged. The window collects new elements until the timer fires. At that point, the window is evaluated and purged.

Upvotes: 1

Related Questions