Class ProcessingTimeSessionWindows
- 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.ProcessingTimeSessionWindows
-
- All Implemented Interfaces:
Serializable
@PublicEvolving public class ProcessingTimeSessionWindows extends org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
AWindowAssignerthat windows elements into sessions based on the current processing time. 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(ProcessingTimeSessionWindows.withGap(Duration.ofMinutes(1)));- See Also:
- Serialized Form
-
-
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>
-
-
Field Summary
Fields Modifier and Type Field Description protected longsessionTimeout
-
Constructor Summary
Constructors Modifier Constructor Description protectedProcessingTimeSessionWindows(long sessionTimeout)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<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>getDefaultTrigger()org.apache.flink.api.common.typeutils.TypeSerializer<org.apache.flink.streaming.api.windowing.windows.TimeWindow>getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig)booleanisEventTime()voidmergeWindows(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.StringtoString()static <T> DynamicProcessingTimeSessionWindows<T>withDynamicGap(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor)Creates a newSessionWindowsWindowAssignerthat assigns elements to sessions based on the element timestamp.static ProcessingTimeSessionWindowswithGap(Duration size)Creates a newSessionWindowsWindowAssignerthat assigns elements to sessions based on the element timestamp.
-
-
-
Method Detail
-
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>
-
withGap
public static ProcessingTimeSessionWindows withGap(Duration size)
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> DynamicProcessingTimeSessionWindows<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>
-
-