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>
AWindowAssigner
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:
- 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 long
sessionTimeout
-
Constructor Summary
Constructors Modifier Constructor Description protected
EventTimeSessionWindows(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)
boolean
isEventTime()
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 overlappingTimeWindow
s.String
toString()
static <T> DynamicEventTimeSessionWindows<T>
withDynamicGap(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor)
Creates a newSessionWindows
WindowAssigner
that assigns elements to sessions based on the element timestamp.static EventTimeSessionWindows
withGap(Duration size)
Creates a newSessionWindows
WindowAssigner
that 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:
assignWindows
in 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:
getDefaultTrigger
in classorg.apache.flink.streaming.api.windowing.assigners.WindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
-
withGap
public static EventTimeSessionWindows withGap(Duration size)
Creates a newSessionWindows
WindowAssigner
that 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 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 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:
getWindowSerializer
in classorg.apache.flink.streaming.api.windowing.assigners.WindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
-
isEventTime
public boolean isEventTime()
- Specified by:
isEventTime
in 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 overlappingTimeWindow
s.- Specified by:
mergeWindows
in classorg.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner<Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow>
-
-