public class WindowDefinition extends Object implements Serializable
A frame is labelled with its timestamp, which is the first timestamp value beyond the range covered by the frame. That timestamp denotes the exact moment on the event timeline where the frame was closed.
Modifier and Type | Method and Description |
---|---|
long |
floorFrameTs(long timestamp)
Returns the highest frame timestamp less than or equal to the given
timestamp.
|
long |
frameLength()
Returns the length of the frame (equal to the sliding step).
|
long |
frameOffset()
Returns the frame offset.
|
long |
higherFrameTs(long timestamp)
Returns the lowest frame timestamp greater than the given timestamp.
|
boolean |
isTumbling()
Tells whether this definition describes a tumbling window.
|
static WindowDefinition |
slidingWindowDef(long windowLength,
long slideBy)
Returns the definition of a sliding window of length
windowLength that slides by slideBy . |
WindowDefinition |
toTumblingByFrame()
Converts this definition to one defining a tumbling window of the
same length as this definition's frame.
|
static WindowDefinition |
tumblingWindowDef(long windowLength)
Returns the definition of a tumbling window of length
windowLength . |
long |
windowLength()
Returns the length of the window (the size of the timestamp range it covers).
|
WindowDefinition |
withOffset(long offset)
Returns a new window definition where all the frames are shifted by the
given offset.
|
public long frameLength()
public long frameOffset()
frameLength = 10
and
frameOffset = 5
the frames will start at 5, 15, 25...public long windowLength()
frameLength()
.public boolean isTumbling()
public long floorFrameTs(long timestamp)
long
value, returns Long.MIN_VALUE
.public long higherFrameTs(long timestamp)
long
value, returns Long.MAX_VALUE
.public WindowDefinition withOffset(long offset)
Given a tumbling window of windowLength = 4
, with no offset the
windows would cover the timestamps ..., [-4, 0), [0..4), ...
With offset = 2
they will cover ..., [-2, 2), [2..6),
...
public WindowDefinition toTumblingByFrame()
public static WindowDefinition slidingWindowDef(long windowLength, long slideBy)
windowLength
that slides by slideBy
. Given windowLength = 4
and slideBy = 2
, the generated windows would
cover timestamps ..., [-2, 2), [0..4), [2..6), [4..8), [6..10),
...
Since the window will be computed internally by maintaining frames
of size equal to the sliding step, the
configured window length must be an integer multiple of the sliding
step.
windowLength
- the length of the window, must be a multiple of slideBy
slideBy
- the amount to slide the window bypublic static WindowDefinition tumblingWindowDef(long windowLength)
windowLength
. The tumbling window is a special case of the sliding
window with slideBy = windowLength
. Given windowLength = 4
, the generated windows would cover timestamps ..., [-4, 0), [0..4), [4..8), ...
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.