In a WindowAssigner
, an element gets assigned to one or more TimeWindow
instances. In case of a sliding event time window, this happens in SlidingEventTimeWindows#assignWindows
1.
In case of a window with size=5
and slide=1
, an element with timestamp=0
gets assigned into the following windows:
- Window(start=0, end=5)
- Window(start=-1, end=4)
- Window(start=-2, end=3)
- Window(start=-3, end=2)
- Window(start=-4, end=1)
In one picture:
+-> Beginning of time
|
|
+----------------------------------------------+
| size = 5 +--+ element |
| slide = 1 | |
| v |
| t=[ 0,5[ Window 1 XXXXX |
| t=[-1,4[ Window 2 XXXXX |
| t=[-2,3[ Window 3 XXXXX |
| t=[-3,2[ Window 4 XXXXX |
| t=[-4,1[ Window 5 XXXXX |
| |
| time(-4 to +4) ---- |
| 432101234 |
+---------------------------+------------------+
|
|
|
+
Is there a way to tell Flink that there is a beginning of time and before, there are no windows? If not, where to start looking to change that? In the above case, Flink should have only one window (t=[4,8[ Window 1
) for the first element. Like this:
+-> Beginning of time
|
|
+-----------------------------------------------+
| size = 5 +--+ element |
| slide = 1 | |
| v |
| t=[ 0,5[ Window 1 XXXXX |
| t=[ 1,6[ Window 2 XXXXX |
| t=[ 2,7[ Window 3 XXXXX |
| t=[ 3,8[ Window 4 XXXXX |
| t=[ 4,9[ Window 5 XXXXX |
| |
| time(-4 to +8) ---- |
| 4321012345678 |
+---------------------------+-------------------+
|
|
|
+
This will have no more effect once the number of windows reaches and exceeds window size. Then, in the above case, all elements are inside of 5 Windows.
Footnotes:
org.apache.flink.streaming.api.windowing.assigners.SlidingEventTimeWindows#assignWindows