public class SessionWindowAssigner extends MergingWindowAssigner<TimeWindow> implements InternalTimeWindowAssigner
GroupWindowAssigner that windows elements into sessions based on the timestamp. Windows
cannot overlap.| Modifier | Constructor and Description |
|---|---|
protected |
SessionWindowAssigner(long sessionGap,
boolean isEventTime) |
| Modifier and Type | Method and Description |
|---|---|
Collection<TimeWindow> |
assignWindows(org.apache.flink.table.data.RowData element,
long timestamp)
Given the timestamp and element, returns the set of windows into which it should be placed.
|
org.apache.flink.api.common.typeutils.TypeSerializer<TimeWindow> |
getWindowSerializer(org.apache.flink.api.common.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,
MergeCallback<TimeWindow,Collection<TimeWindow>> callback)
Determines which windows (if any) should be merged.
|
String |
toString() |
SessionWindowAssigner |
withEventTime() |
static SessionWindowAssigner |
withGap(Duration size)
Creates a new
SessionWindowAssigner GroupWindowAssigner that assigns elements
to sessions based on the timestamp. |
SessionWindowAssigner |
withProcessingTime() |
openprotected SessionWindowAssigner(long sessionGap,
boolean isEventTime)
public Collection<TimeWindow> assignWindows(org.apache.flink.table.data.RowData element, long timestamp)
GroupWindowAssignerassignWindows in class GroupWindowAssigner<TimeWindow>element - The element to which windows should be assigned.timestamp - The timestamp of the element when GroupWindowAssigner.isEventTime() returns true, or
the current system time when GroupWindowAssigner.isEventTime() returns false. The timestamp value is
mapping to UTC milliseconds for splitting windows simply.public void mergeWindows(TimeWindow newWindow, NavigableSet<TimeWindow> sortedWindows, MergeCallback<TimeWindow,Collection<TimeWindow>> callback)
MergingWindowAssignermergeWindows 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 org.apache.flink.api.common.typeutils.TypeSerializer<TimeWindow> getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig)
GroupWindowAssignerTypeSerializer for serializing windows that are assigned by this WindowAssigner.getWindowSerializer in class GroupWindowAssigner<TimeWindow>public boolean isEventTime()
GroupWindowAssignertrue if elements are assigned to windows based on event time, false
otherwise.isEventTime in class GroupWindowAssigner<TimeWindow>public String toString()
toString in class GroupWindowAssigner<TimeWindow>public static SessionWindowAssigner withGap(Duration size)
SessionWindowAssigner GroupWindowAssigner 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 InternalTimeWindowAssignerpublic SessionWindowAssigner withProcessingTime()
withProcessingTime in interface InternalTimeWindowAssignerCopyright © 2014–2025 The Apache Software Foundation. All rights reserved.