Class ProcessingTimeSessionWindows
java.lang.Object
org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<T,W>
org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner<Object,TimeWindow>
org.apache.flink.streaming.api.windowing.assigners.ProcessingTimeSessionWindows
- All Implemented Interfaces:
Serializable
@PublicEvolving
public class ProcessingTimeSessionWindows
extends MergingWindowAssigner<Object,TimeWindow>
A
WindowAssigner that 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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner
MergingWindowAssigner.MergeCallback<W>Nested classes/interfaces inherited from class org.apache.flink.streaming.api.windowing.assigners.WindowAssigner
WindowAssigner.WindowAssignerContext -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassignWindows(Object element, long timestamp, WindowAssigner.WindowAssignerContext context) Returns aCollectionof windows that should be assigned to the element.Returns the default trigger associated with thisWindowAssigner.getWindowSerializer(ExecutionConfig executionConfig) Returns aTypeSerializerfor serializing windows that are assigned by thisWindowAssigner.booleanReturnstrueif elements are assigned to windows based on event time,falseotherwise.voidMerge overlappingTimeWindows.toString()static <T> DynamicProcessingTimeSessionWindows<T>withDynamicGap(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor) Creates a newSessionWindowsWindowAssignerthat assigns elements to sessions based on the element timestamp.static ProcessingTimeSessionWindowsCreates a newSessionWindowsWindowAssignerthat assigns elements to sessions based on the element timestamp.
-
Field Details
-
sessionTimeout
protected long sessionTimeout
-
-
Constructor Details
-
ProcessingTimeSessionWindows
protected ProcessingTimeSessionWindows(long sessionTimeout)
-
-
Method Details
-
assignWindows
public Collection<TimeWindow> assignWindows(Object element, long timestamp, WindowAssigner.WindowAssignerContext context) Description copied from class:WindowAssignerReturns aCollectionof windows that should be assigned to the element.- Specified by:
assignWindowsin classWindowAssigner<Object,TimeWindow> - Parameters:
element- The element to which windows should be assigned.timestamp- The timestamp of the element.context- TheWindowAssigner.WindowAssignerContextin which the assigner operates.
-
getDefaultTrigger
Description copied from class:WindowAssignerReturns the default trigger associated with thisWindowAssigner.1. If you override
getDefaultTrigger(), thegetDefaultTrigger()will be invoked and thegetDefaultTrigger(StreamExecutionEnvironment env)won't be invoked. 2. If you don't overridegetDefaultTrigger(), thegetDefaultTrigger(StreamExecutionEnvironment env)will be invoked in the default implementation of thegetDefaultTrigger().- Specified by:
getDefaultTriggerin classWindowAssigner<Object,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> 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
Description copied from class:WindowAssignerReturns aTypeSerializerfor serializing windows that are assigned by thisWindowAssigner.- Specified by:
getWindowSerializerin classWindowAssigner<Object,TimeWindow>
-
isEventTime
public boolean isEventTime()Description copied from class:WindowAssignerReturnstrueif elements are assigned to windows based on event time,falseotherwise.- Specified by:
isEventTimein classWindowAssigner<Object,TimeWindow>
-
mergeWindows
public void mergeWindows(Collection<TimeWindow> windows, MergingWindowAssigner.MergeCallback<TimeWindow> c) Merge overlappingTimeWindows.- Specified by:
mergeWindowsin classMergingWindowAssigner<Object,TimeWindow> - Parameters:
windows- The window candidates.c- A callback that can be invoked to signal which windows should be merged.
-