public class SessionWindowAssigner extends MergingWindowAssigner<TimeWindow> implements InternalTimeWindowAssigner
WindowAssigner
that windows elements into sessions based on the timestamp. Windows
cannot overlap.MergingWindowAssigner.MergeCallback<W>
Modifier | Constructor and Description |
---|---|
protected |
SessionWindowAssigner(long sessionGap,
boolean isEventTime) |
Modifier and Type | Method and Description |
---|---|
Collection<TimeWindow> |
assignWindows(RowData element,
long timestamp)
Given the timestamp and element, returns the set of windows into which it should be placed.
|
TypeSerializer<TimeWindow> |
getWindowSerializer(ExecutionConfig executionConfig)
Returns a
TypeSerializer for serializing windows that are assigned by this WindowAssigner . |
boolean |
isEventTime()
Returns
true if elements are assigned to windows based on event time, false
otherwise. |
void |
mergeWindows(TimeWindow newWindow,
NavigableSet<TimeWindow> sortedWindows,
MergingWindowAssigner.MergeCallback<TimeWindow> callback)
Determines which windows (if any) should be merged.
|
String |
toString() |
SessionWindowAssigner |
withEventTime() |
static SessionWindowAssigner |
withGap(java.time.Duration size)
Creates a new
SessionWindowAssigner WindowAssigner that assigns elements to
sessions based on the timestamp. |
SessionWindowAssigner |
withProcessingTime() |
open
protected SessionWindowAssigner(long sessionGap, boolean isEventTime)
public Collection<TimeWindow> assignWindows(RowData element, long timestamp)
WindowAssigner
assignWindows
in class WindowAssigner<TimeWindow>
element
- The element to which windows should be assigned.timestamp
- The timestamp of the element when WindowAssigner.isEventTime()
returns true, or
the current system time when WindowAssigner.isEventTime()
returns false. The timestamp value is
mapping to UTC milliseconds for splitting windows simply.public void mergeWindows(TimeWindow newWindow, NavigableSet<TimeWindow> sortedWindows, MergingWindowAssigner.MergeCallback<TimeWindow> callback)
MergingWindowAssigner
mergeWindows
in class MergingWindowAssigner<TimeWindow>
newWindow
- The new windowsortedWindows
- The sorted window candidates.callback
- A callback that can be invoked to signal which windows should be merged.public TypeSerializer<TimeWindow> getWindowSerializer(ExecutionConfig executionConfig)
WindowAssigner
TypeSerializer
for serializing windows that are assigned by this WindowAssigner
.getWindowSerializer
in class WindowAssigner<TimeWindow>
public boolean isEventTime()
WindowAssigner
true
if elements are assigned to windows based on event time, false
otherwise.isEventTime
in class WindowAssigner<TimeWindow>
public String toString()
toString
in class WindowAssigner<TimeWindow>
public static SessionWindowAssigner withGap(java.time.Duration size)
SessionWindowAssigner
WindowAssigner
that assigns elements to
sessions based on the timestamp.size
- The session timeout, i.e. the time gap between sessionspublic SessionWindowAssigner withEventTime()
withEventTime
in interface InternalTimeWindowAssigner
public SessionWindowAssigner withProcessingTime()
withProcessingTime
in interface InternalTimeWindowAssigner
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.