public class EventTimeSessionWindows extends MergingWindowAssigner<Object,TimeWindow>
WindowAssigner
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(Time.minutes(1)));
MergingWindowAssigner.MergeCallback<W>
WindowAssigner.WindowAssignerContext
Modifier and Type | Field and Description |
---|---|
protected long |
sessionTimeout |
Modifier | Constructor and Description |
---|---|
protected |
EventTimeSessionWindows(long sessionTimeout) |
Modifier and Type | Method and Description |
---|---|
Collection<TimeWindow> |
assignWindows(Object element,
long timestamp,
WindowAssigner.WindowAssignerContext context)
Returns a
Collection of windows that should be assigned to the element. |
Trigger<Object,TimeWindow> |
getDefaultTrigger(StreamExecutionEnvironment env)
Returns the default trigger associated with this
WindowAssigner . |
TypeSerializer<TimeWindow> |
getWindowSerializer(ExecutionConfig executionConfig)
Returns a
TypeSerializer for serializing windows that are assigned by
this WindowAssigner . |
boolean |
isEventTime()
Returns
true if elements are assigned to windows based on event time,
false otherwise. |
void |
mergeWindows(Collection<TimeWindow> windows,
MergingWindowAssigner.MergeCallback<TimeWindow> c)
Merge overlapping
TimeWindow s. |
String |
toString() |
static <T> DynamicEventTimeSessionWindows<T> |
withDynamicGap(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor)
Creates a new
SessionWindows WindowAssigner that assigns
elements to sessions based on the element timestamp. |
static EventTimeSessionWindows |
withGap(Time size)
Creates a new
SessionWindows WindowAssigner that assigns
elements to sessions based on the element timestamp. |
public Collection<TimeWindow> assignWindows(Object element, long timestamp, WindowAssigner.WindowAssignerContext context)
WindowAssigner
Collection
of windows that should be assigned to the element.assignWindows
in class WindowAssigner<Object,TimeWindow>
element
- The element to which windows should be assigned.timestamp
- The timestamp of the element.context
- The WindowAssigner.WindowAssignerContext
in which the assigner operates.public Trigger<Object,TimeWindow> getDefaultTrigger(StreamExecutionEnvironment env)
WindowAssigner
WindowAssigner
.getDefaultTrigger
in class WindowAssigner<Object,TimeWindow>
public static EventTimeSessionWindows withGap(Time size)
SessionWindows
WindowAssigner
that assigns
elements to sessions based on the element timestamp.size
- The session timeout, i.e. the time gap between sessions@PublicEvolving public static <T> DynamicEventTimeSessionWindows<T> withDynamicGap(SessionWindowTimeGapExtractor<T> sessionWindowTimeGapExtractor)
SessionWindows
WindowAssigner
that assigns
elements to sessions based on the element timestamp.sessionWindowTimeGapExtractor
- The extractor to use to extract the time gap from the input elementspublic TypeSerializer<TimeWindow> getWindowSerializer(ExecutionConfig executionConfig)
WindowAssigner
TypeSerializer
for serializing windows that are assigned by
this WindowAssigner
.getWindowSerializer
in class WindowAssigner<Object,TimeWindow>
public boolean isEventTime()
WindowAssigner
true
if elements are assigned to windows based on event time,
false
otherwise.isEventTime
in class WindowAssigner<Object,TimeWindow>
public void mergeWindows(Collection<TimeWindow> windows, MergingWindowAssigner.MergeCallback<TimeWindow> c)
TimeWindow
s.mergeWindows
in class MergingWindowAssigner<Object,TimeWindow>
windows
- The window candidates.c
- A callback that can be invoked to signal which windows should be merged.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.