Tumbling windows
A tumbling window stores incoming tuples until the window is full, then executes the operator behavior, and finally flushes all stored tuples, before it starts over from scratch.
- Count eviction policy count(n): Count-based window, storing n tuples. For example, with the eviction policy count(4), the window tumbles at every fourth input tuple.Sample window configuration:
CountWindowPolicy pc4(4), pc2(2); TumblingWindow<TT> wT_C4(op, 0, pC4);
Tumbling sequence:
- Time eviction policy time(t): Time-based window, storing tuples that arrive over a period of t seconds. For example, with the eviction policy time(5), the window tumbles every five seconds. At eviction, the window can contain any number of tuples; it can even be empty.
- Delta eviction policy delta(attribute, delta): Attribute-delta based window, storing tuples until the difference between the value of attribute attribute of the newest and the oldest tuple exceeds delta, the delta. More formally, the window is full if this condition is true:
Ttemperature - Toldesttemperature > delta
For example, with the eviction policy delta(temperature, 1.5), if the window contained tuples with the temperature values [17.1, 16.4, 16.0], sorted newest to oldest, an input tuple with the temperature value 17.6 would tumble the window because the delta between the newest value (17.6) and the oldest value (16.0) exceeds 1.5.
The tuple that tumbles the window is not part of the eviction but is inserted into the window after the eviction.
The attribute is typically monotonically increasing, and is often a time stamp. In this case, the delta delta represents seconds, and the difference in seconds between the timestamp values of the newest and the oldest tuple is compared to the delta. Thus, an attribute-delta based window can emulate a time-based window, but instead of using the current time on the local computer, it uses a time attribute streamed along with the data.
- Window punctuation eviction policy punct(): Punctuation-based window, storing tuples until the next window punctuation arrives. An upstream operator can generate punctuation, and a downstream operator can use them for windowing.
For example, the FileSource operator submits a window punctuation mark at the end of each file, so that a windowed operator that uses punctuation-based eviction can execute some function on the set of tuples that make up the contents of the file.
Operators that support windowing usually submit a window punctuation mark after they tumbled to indicate the set of tuples that resulted from processing the input windowed set of tuples. This mark is submitted regardless of the eviction policy.