public abstract class WindowDefinition extends Object
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 earlyResultPeriod)
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 earlyResultPeriod)
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".
earlyResultPeriod
- 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)
Find more information in the Hazelcast Jet Reference Manual, Sliding and Tumbling Window.
windowSize
- the size of the window (size of the range of the timestamps it covers)slideBy
- the size of the sliding step. Window size must be multiple of this number.@Nonnull public static SlidingWindowDefinition tumbling(long windowSize)
windowSize
- the size of the window (size of the range of the timestamps it covers)@Nonnull public static SessionWindowDefinition session(long sessionTimeout)
The functioning of session windows is easiest to explain in terms of the
event interval: the range [timestamp, timestamp +
sessionTimeout)
. Initially an event causes a new session window to be
created, covering exactly the event interval. A following event under
the same key belongs to this window iff its interval overlaps it. The
window is extended to cover the entire interval of the new event. The
event may happen to belong to two existing windows if its interval
bridges the gap between them; in that case they are combined into one.
For example: say E(n)
is an event with timestamp n
and
W(m, n)
is a window with startTime=m
and endTime=n
. Session timeout is 10. We receive E(50)
, we'll store
it in a window W(50, 60)
. Then, job is updated and session
timeout changes to 20. If we then receive E(45)
, we'll handle it
as merging of the restored W(50, 60)
and of W(45, 65)
,
created from the new event and new timeout. It will result in W(45, 65)
. Thus, the actual session timeout in this window will be 15.
sessionTimeout
- the exclusive upper bound on the difference between any two
successive timestamps included in a window.Copyright © 2019 Hazelcast, Inc.. All rights reserved.