Class DynamicProcessingTimeSessionWindows<T>
- java.lang.Object
-
- org.apache.flink.streaming.api.windowing.assigners.WindowAssigner<T,W>
-
- org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner<T,TimeWindow>
-
- org.apache.flink.streaming.api.windowing.assigners.DynamicProcessingTimeSessionWindows<T>
-
- Type Parameters:
T- The type of the input elements
- All Implemented Interfaces:
Serializable
@PublicEvolving public class DynamicProcessingTimeSessionWindows<T> extends MergingWindowAssigner<T,TimeWindow>
AWindowAssignerthat windows elements into sessions based on the current processing time. Windows cannot overlap.For example, in order to window into windows with a dynamic time gap:
DataStream<Tuple2<String, Integer>> in = ...; KeyedStream<String, Tuple2<String, Integer>> keyed = in.keyBy(...); WindowedStream<Tuple2<String, Integer>, String, TimeWindows> windowed = keyed.window(DynamicProcessingTimeSessionWindows.withDynamicGap({@link SessionWindowTimeGapExtractor }));- See Also:
- Serialized Form
-
-
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 Modifier and Type Field Description protected SessionWindowTimeGapExtractor<T>sessionWindowTimeGapExtractor
-
Constructor Summary
Constructors Modifier Constructor Description protectedDynamicProcessingTimeSessionWindows(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<TimeWindow>assignWindows(T element, long timestamp, WindowAssigner.WindowAssignerContext context)Returns aCollectionof windows that should be assigned to the element.Trigger<T,TimeWindow>getDefaultTrigger()Returns the default trigger associated with thisWindowAssigner.Trigger<T,TimeWindow>getDefaultTrigger(StreamExecutionEnvironment env)Returns the default trigger associated with thisWindowAssigner.org.apache.flink.api.common.typeutils.TypeSerializer<TimeWindow>getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig)Returns aTypeSerializerfor serializing windows that are assigned by thisWindowAssigner.booleanisEventTime()Returnstrueif elements are assigned to windows based on event time,falseotherwise.voidmergeWindows(Collection<TimeWindow> windows, MergingWindowAssigner.MergeCallback<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.
-
-
-
Field Detail
-
sessionWindowTimeGapExtractor
protected SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor
-
-
Constructor Detail
-
DynamicProcessingTimeSessionWindows
protected DynamicProcessingTimeSessionWindows(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor)
-
-
Method Detail
-
assignWindows
public Collection<TimeWindow> assignWindows(T element, long timestamp, WindowAssigner.WindowAssignerContext context)
Description copied from class:WindowAssignerReturns aCollectionof windows that should be assigned to the element.- Specified by:
assignWindowsin classWindowAssigner<T,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
public Trigger<T,TimeWindow> getDefaultTrigger(StreamExecutionEnvironment env)
Description copied from class:WindowAssignerReturns the default trigger associated with thisWindowAssigner.- Specified by:
getDefaultTriggerin classWindowAssigner<T,TimeWindow>- See Also:
- FLIP-343: Remove parameter in WindowAssigner#getDefaultTrigger()
-
getDefaultTrigger
public Trigger<T,TimeWindow> 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().- Overrides:
getDefaultTriggerin classWindowAssigner<T,TimeWindow>
-
withDynamicGap
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<TimeWindow> getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig)
Description copied from class:WindowAssignerReturns aTypeSerializerfor serializing windows that are assigned by thisWindowAssigner.- Specified by:
getWindowSerializerin classWindowAssigner<T,TimeWindow>
-
isEventTime
public boolean isEventTime()
Description copied from class:WindowAssignerReturnstrueif elements are assigned to windows based on event time,falseotherwise.- Specified by:
isEventTimein classWindowAssigner<T,TimeWindow>
-
mergeWindows
public void mergeWindows(Collection<TimeWindow> windows, MergingWindowAssigner.MergeCallback<TimeWindow> c)
Merge overlappingTimeWindows.- Specified by:
mergeWindowsin classMergingWindowAssigner<T,TimeWindow>- Parameters:
windows- The window candidates.c- A callback that can be invoked to signal which windows should be merged.
-
-