public class Sessions extends WindowFn<Object,IntervalWindow>
WindowFn windowing values into sessions separated by gapDuration-long
periods with no elements.
For example, in order to window data into session with at least 10 minute gaps in between them:
PCollection<Integer> pc = ...;
PCollection<Integer> windowed_pc = pc.apply(
Window.<Integer>into(Sessions.withGapDuration(Duration.standardMinutes(10))));
WindowFn.AssignContext, WindowFn.MergeContext| Modifier and Type | Method and Description |
|---|---|
Collection<IntervalWindow> |
assignWindows(WindowFn.AssignContext c)
Given a timestamp and element, returns the set of windows into which it
should be placed.
|
boolean |
equals(Object object) |
Duration |
getGapDuration() |
OutputTimeFn<? super IntervalWindow> |
getOutputTimeFn()
Provides a default implementation for
WindowingStrategy.getOutputTimeFn(). |
IntervalWindow |
getSideInputWindow(BoundedWindow window)
Returns the window of the side input corresponding to the given window of
the main input.
|
int |
hashCode() |
boolean |
isCompatible(WindowFn<?,?> other)
Returns whether this performs the same merging as the given
WindowFn. |
void |
mergeWindows(WindowFn.MergeContext c)
Does whatever merging of windows is necessary.
|
Coder<IntervalWindow> |
windowCoder()
Returns the
Coder used for serializing the windows used
by this windowFn. |
static Sessions |
withGapDuration(Duration gapDuration)
Creates a
Sessions WindowFn with the specified gap duration. |
assignsToSingleWindow, getOutputTime, isNonMergingpublic static Sessions withGapDuration(Duration gapDuration)
Sessions WindowFn with the specified gap duration.public Collection<IntervalWindow> assignWindows(WindowFn.AssignContext c)
WindowFnassignWindows in class WindowFn<Object,IntervalWindow>public void mergeWindows(WindowFn.MergeContext c) throws Exception
WindowFnSee MergeOverlappingIntervalWindows.mergeWindows(com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn<?, com.google.cloud.dataflow.sdk.transforms.windowing.IntervalWindow>.MergeContext) for an
example of how to override this method.
mergeWindows in class WindowFn<Object,IntervalWindow>Exceptionpublic Coder<IntervalWindow> windowCoder()
WindowFnCoder used for serializing the windows used
by this windowFn.windowCoder in class WindowFn<Object,IntervalWindow>public boolean isCompatible(WindowFn<?,?> other)
WindowFnWindowFn.isCompatible in class WindowFn<Object,IntervalWindow>public IntervalWindow getSideInputWindow(BoundedWindow window)
WindowFnAuthors of custom WindowFns should override this.
getSideInputWindow in class WindowFn<Object,IntervalWindow>@Experimental(value=OUTPUT_TIME) public OutputTimeFn<? super IntervalWindow> getOutputTimeFn()
WindowFnWindowingStrategy.getOutputTimeFn().
See the full specification there.
If this WindowFn doesn't produce overlapping windows, this need not (and probably
should not) override any of the default implementations in OutputTimeFn.Defaults.
If this WindowFn does produce overlapping windows that can be predicted here, it is
suggested that the result in later overlapping windows is past the end of earlier windows so
that the later windows don't prevent the watermark from progressing past the end of the earlier
window.
For example, a timestamp in a sliding window should be moved past the beginning of the next
sliding window. See SlidingWindows.getOutputTimeFn().
getOutputTimeFn in class WindowFn<Object,IntervalWindow>public Duration getGapDuration()