public class SlidingWindowPolicy 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 |
frameOffset()
Returns the frame offset.
|
long |
frameSize()
Returns the length of the frame (equal to the sliding step).
|
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 SlidingWindowPolicy |
slidingWinPolicy(long windowSize,
long slideBy)
Returns the definition of a sliding window of length
windowSize that slides by slideBy . |
SlidingWindowPolicy |
toTumblingByFrame()
Converts this definition to one defining a tumbling window of the
same length as this definition's frame.
|
static SlidingWindowPolicy |
tumblingWinPolicy(long windowSize)
Returns the definition of a tumbling window of length
windowSize . |
long |
windowSize()
Returns the length of the window (the size of the timestamp range it covers).
|
SlidingWindowPolicy |
withOffset(long offset)
Returns a new window definition where all the frames are shifted by the
given offset.
|
public long frameSize()
public long frameOffset()
frameLength = 10
and
frameOffset = 5
the frames will start at 5, 15, 25...public long windowSize()
frameSize()
.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 SlidingWindowPolicy 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 SlidingWindowPolicy toTumblingByFrame()
public static SlidingWindowPolicy slidingWinPolicy(long windowSize, long slideBy)
windowSize
that slides by slideBy
. Given windowSize = 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.
windowSize
- the length of the window, must be a multiple of slideBy
slideBy
- the amount to slide the window bypublic static SlidingWindowPolicy tumblingWinPolicy(long windowSize)
windowSize
. The tumbling window is a special case of the sliding
window with slideBy = windowSize
. Given windowSize = 4
, the generated windows would cover timestamps ..., [-4, 0), [0..4), [4..8), ...
Copyright © 2021 Hazelcast, Inc.. All rights reserved.