Class WindowDefinition
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SessionWindowDefinition
,SlidingWindowDefinition
- Since:
- Jet 3.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
Returns the early results period for this window definition.static SessionWindowDefinition
session
(long sessionTimeout) Returns a window definition that aggregates events into session windows.setEarlyResultsPeriod
(long earlyResultPeriodMs) Sets the period in milliseconds at which the windowed aggregation stage will emit partial results of all the windows that contain some data, but the watermark hasn't yet advanced enough to close them and emit the final results.static SlidingWindowDefinition
sliding
(long windowSize, long slideBy) Returns a sliding window definition with the given parameters.static SlidingWindowDefinition
tumbling
(long windowSize) Returns a tumbling window definition with the given parameters.
-
Constructor Details
-
WindowDefinition
public WindowDefinition()
-
-
Method Details
-
earlyResultsPeriod
public long earlyResultsPeriod()Returns the early results period for this window definition. A return value of zero means that the stage won't emit early window results.- Since:
- Jet 3.1
-
setEarlyResultsPeriod
Sets the period in milliseconds at which the windowed aggregation stage will emit partial results of all the windows that contain some data, but the watermark hasn't yet advanced enough to close them and emit the final results.Consider this example: we're collecting a 1-minute tumbling window of stock exchange data. The results we're getting pertain to the minute that just elapsed, but we'd also like to detect any sudden changes within the running minute. We can set the early results period to 1000 ms and get an update every second for the window that's currently being filled with data.
Note that, for a sliding window, there will be many incomplete windows that contain some data, and you'll get the early results for all of them. Similarly, if you configure a high-enough
maxLag
for the event timestamps, there can be more than one tumbling/session window with early results.The default value is zero, which means "don't emit early results".
- Parameters:
earlyResultPeriodMs
- the period in milliseconds from one start of the emission of early results to the next one- Returns:
this
- Since:
- Jet 3.1
-
sliding
Returns a sliding window definition with the given parameters. In a sliding window, the incoming items are grouped by fixed-size and overlapping intervals where the windows "slide" by the given size.For example, given the timestamps
[0, 1, 2, 3, 4, 5, 6]
,windowSize
of 4 and@slideBy
of 2, the timestamps would be grouped into the following windows:[0, 1], [0, 1, 2, 3], [2, 3, 4, 5], [4, 5, 6], [6]
A sliding window where window size and slide by are the same is equivalent to a tumbling window.Find more information see the Hazelcast Jet Reference Manual section Sliding and Tumbling Window.
- Parameters:
windowSize
- the size of the window in the items' timestamp unit (typically milliseconds)slideBy
- the size of the sliding step. Window size must be multiple of this number.
-
tumbling
Returns a tumbling window definition with the given parameters. In a tumbling window the incoming items are grouped by fixed size, contiguous and non-overlapping intervals.For example, given the timestamps
[0, 1, 2, 3, 4, 5, 6]
and awindowSize
of 2, the timestamps would be grouped into the following windows:[0, 1], [2, 3], [4, 5], [6]
- Parameters:
windowSize
- the size of the window in the items' timestamp unit (typically milliseconds)
-
session
Returns a window definition that aggregates events into session windows. In a session window, the items are grouped into variable size, non-overlapping windows which are formed by periods of activity followed by inactivity. A session window is kept open as long as the gap between the events remains less than the givensessionTimeout
and is closed when the gap exceeds the timeout.For example, given the timestamps
[0, 1, 4, 8, 9, 10, 15]
and asessionTimeout
of 2, the timestamps would be grouped into the following windows:[0, 1], [4], [8, 9, 10], [15]
- Parameters:
sessionTimeout
- the upper bound on the difference between any two consecutive timestamps in a window, given in the items' timestamp unit (typically milliseconds)
-