Class EventTimeSessionWindows
java.lang.Object
org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<T,W>
org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
org.apache.flink.streaming.api.windowing.assigners.EventTimeSessionWindows
- All Implemented Interfaces:
Serializable
@PublicEvolving
public class EventTimeSessionWindows
extends org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
A
WindowAssigner that windows elements into sessions based on the timestamp of the
elements. Windows cannot overlap.
For example, in order to window into windows of 1 minute, every 10 seconds:
DataStream<Tuple2<String, Integer>> in = ...;
KeyedStream<String, Tuple2<String, Integer>> keyed = in.keyBy(...);
WindowedStream<Tuple2<String, Integer>, String, TimeWindows> windowed =
keyed.window(EventTimeSessionWindows.withGap(Duration.ofMinutes(1)));
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner
org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner.MergeCallback<W extends Object>Nested classes/interfaces inherited from class org.apache.flink.streaming.api.windowing.assigners.WindowAssigner
org.apache.flink.streaming.api.windowing.assigners.WindowAssigner.WindowAssignerContext -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCollection<org.apache.flink.streaming.api.windowing.windows.TimeWindow>assignWindows(Object element, long timestamp, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner.WindowAssignerContext context) org.apache.flink.streaming.api.windowing.triggers.Trigger<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow> org.apache.flink.api.common.typeutils.TypeSerializer<org.apache.flink.streaming.api.windowing.windows.TimeWindow>getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig) booleanvoidmergeWindows(Collection<org.apache.flink.streaming.api.windowing.windows.TimeWindow> windows, org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner.MergeCallback<org.apache.flink.streaming.api.windowing.windows.TimeWindow> c) Merge overlappingTimeWindows.toString()static <T> DynamicEventTimeSessionWindows<T>withDynamicGap(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor) Creates a newSessionWindowsWindowAssignerthat assigns elements to sessions based on the element timestamp.static EventTimeSessionWindowsCreates a newSessionWindowsWindowAssignerthat assigns elements to sessions based on the element timestamp.
-
Field Details
-
sessionTimeout
protected long sessionTimeout
-
-
Constructor Details
-
EventTimeSessionWindows
protected EventTimeSessionWindows(long sessionTimeout)
-
-
Method Details
-
assignWindows
public Collection<org.apache.flink.streaming.api.windowing.windows.TimeWindow> assignWindows(Object element, long timestamp, org.apache.flink.streaming.api.windowing.assigners.WindowAssigner.WindowAssignerContext context) - Specified by:
assignWindowsin classorg.apache.flink.streaming.api.windowing.assigners.WindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
-
getDefaultTrigger
public org.apache.flink.streaming.api.windowing.triggers.Trigger<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow> getDefaultTrigger()- Specified by:
getDefaultTriggerin classorg.apache.flink.streaming.api.windowing.assigners.WindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
-
toString
-
withGap
Creates a newSessionWindowsWindowAssignerthat assigns elements to sessions based on the element timestamp.- Parameters:
size- The session timeout, i.e. the time gap between sessions- Returns:
- The policy.
-
withDynamicGap
@PublicEvolving public static <T> DynamicEventTimeSessionWindows<T> withDynamicGap(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor) Creates a newSessionWindowsWindowAssignerthat assigns elements to sessions based on the element timestamp.- Parameters:
sessionWindowTimeGapExtractor- The extractor to use to extract the time gap from the input elements- Returns:
- The policy.
-
getWindowSerializer
public org.apache.flink.api.common.typeutils.TypeSerializer<org.apache.flink.streaming.api.windowing.windows.TimeWindow> getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig) - Specified by:
getWindowSerializerin classorg.apache.flink.streaming.api.windowing.assigners.WindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
-
isEventTime
public boolean isEventTime()- Specified by:
isEventTimein classorg.apache.flink.streaming.api.windowing.assigners.WindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
-
mergeWindows
public void mergeWindows(Collection<org.apache.flink.streaming.api.windowing.windows.TimeWindow> windows, org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner.MergeCallback<org.apache.flink.streaming.api.windowing.windows.TimeWindow> c) Merge overlappingTimeWindows.- Specified by:
mergeWindowsin classorg.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
-