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>
AWindowAssigner
that 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 protected
DynamicProcessingTimeSessionWindows(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 aCollection
of windows that should be assigned to the element.Trigger<T,TimeWindow>
getDefaultTrigger()
Returns the default trigger associated with thisWindowAssigner
.TypeSerializer<TimeWindow>
getWindowSerializer(ExecutionConfig executionConfig)
Returns aTypeSerializer
for serializing windows that are assigned by thisWindowAssigner
.boolean
isEventTime()
Returnstrue
if elements are assigned to windows based on event time,false
otherwise.void
mergeWindows(Collection<TimeWindow> windows, MergingWindowAssigner.MergeCallback<TimeWindow> c)
Merge overlappingTimeWindow
s.String
toString()
static <T> DynamicProcessingTimeSessionWindows<T>
withDynamicGap(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor)
Creates a newSessionWindows
WindowAssigner
that 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:WindowAssigner
Returns aCollection
of windows that should be assigned to the element.- Specified by:
assignWindows
in classWindowAssigner<T,TimeWindow>
- Parameters:
element
- The element to which windows should be assigned.timestamp
- The timestamp of the element.context
- TheWindowAssigner.WindowAssignerContext
in which the assigner operates.
-
getDefaultTrigger
public Trigger<T,TimeWindow> getDefaultTrigger()
Description copied from class:WindowAssigner
Returns 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:
getDefaultTrigger
in classWindowAssigner<T,TimeWindow>
-
withDynamicGap
public static <T> DynamicProcessingTimeSessionWindows<T> withDynamicGap(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor)
Creates a newSessionWindows
WindowAssigner
that 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 TypeSerializer<TimeWindow> getWindowSerializer(ExecutionConfig executionConfig)
Description copied from class:WindowAssigner
Returns aTypeSerializer
for serializing windows that are assigned by thisWindowAssigner
.- Specified by:
getWindowSerializer
in classWindowAssigner<T,TimeWindow>
-
isEventTime
public boolean isEventTime()
Description copied from class:WindowAssigner
Returnstrue
if elements are assigned to windows based on event time,false
otherwise.- Specified by:
isEventTime
in classWindowAssigner<T,TimeWindow>
-
mergeWindows
public void mergeWindows(Collection<TimeWindow> windows, MergingWindowAssigner.MergeCallback<TimeWindow> c)
Merge overlappingTimeWindow
s.- Specified by:
mergeWindows
in classMergingWindowAssigner<T,TimeWindow>
- Parameters:
windows
- The window candidates.c
- A callback that can be invoked to signal which windows should be merged.
-
-