public abstract class WindowDefinition extends Object implements Serializable
Constructor and Description |
---|
WindowDefinition() |
Modifier and Type | Method and Description |
---|---|
long |
earlyResultsPeriod()
Returns the early results period for
this window definition.
|
static SessionWindowDefinition |
session(long sessionTimeout)
Returns a window definition that aggregates events into session windows.
|
WindowDefinition |
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.
|
public long earlyResultsPeriod()
public WindowDefinition setEarlyResultsPeriod(long earlyResultPeriodMs)
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".
earlyResultPeriodMs
- the period in milliseconds from one start of
the emission of early results to the next onethis
@Nonnull public static SlidingWindowDefinition sliding(long windowSize, long slideBy)
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.
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.@Nonnull public static SlidingWindowDefinition tumbling(long windowSize)
For example, given the timestamps
[0, 1, 2, 3, 4, 5, 6]
and a windowSize
of 2, the timestamps
would be grouped into the following windows:
[0, 1], [2, 3], [4, 5], [6]
windowSize
- the size of the window in the items' timestamp unit (typically milliseconds)@Nonnull public static SessionWindowDefinition session(long sessionTimeout)
sessionTimeout
and
is closed when the gap exceeds the timeout.
For example, given the timestamps
[0, 1, 4, 8, 9, 10, 15]
and a sessionTimeout
of 2, the timestamps
would be grouped into the following windows:
[0, 1], [4], [8, 9, 10], [15]
sessionTimeout
- the upper bound on the difference between any two
consecutive timestamps in a window, given in the
items' timestamp unit (typically milliseconds)Copyright © 2024 Hazelcast, Inc.. All rights reserved.