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(BaseRow 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,
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() |
openprotected SessionWindowAssigner(long sessionGap,
boolean isEventTime)
public Collection<TimeWindow> assignWindows(BaseRow element, long timestamp)
WindowAssignerassignWindows 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.public void mergeWindows(TimeWindow newWindow, NavigableSet<TimeWindow> sortedWindows, MergingWindowAssigner.MergeCallback<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)
WindowAssignerTypeSerializer for serializing windows that are assigned by
this WindowAssigner.getWindowSerializer in class WindowAssigner<TimeWindow>public boolean isEventTime()
WindowAssignertrue 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 InternalTimeWindowAssignerpublic SessionWindowAssigner withProcessingTime()
withProcessingTime in interface InternalTimeWindowAssignerCopyright © 2014–2020 The Apache Software Foundation. All rights reserved.