public class Sessions extends WindowingFn<java.lang.Object,IntervalWindow>
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>by(Sessions.withGapDuration(Duration.standardMinutes(10))));
WindowingFn.AssignContext, WindowingFn.MergeContext| Modifier and Type | Method and Description |
|---|---|
java.util.Collection<IntervalWindow> |
assignWindows(WindowingFn.AssignContext c)
Given a timestamp and element, returns the set of windows into which it
should be placed.
|
boolean |
isCompatible(WindowingFn<?,?> other)
Returns whether this performs the same merging as the given
WindowingFn. |
void |
mergeWindows(WindowingFn.MergeContext c)
Does whatever merging of windows is necessary.
|
Coder<IntervalWindow> |
windowCoder()
Returns the
Coder used for serializing the windows used
by this windowingFn. |
static Sessions |
withGapDuration(Duration gapDuration)
Creates a
Sessions WindowingFn with the specified gap duration. |
public static Sessions withGapDuration(Duration gapDuration)
Sessions WindowingFn with the specified gap duration.public java.util.Collection<IntervalWindow> assignWindows(WindowingFn.AssignContext c)
WindowingFnassignWindows in class WindowingFn<java.lang.Object,IntervalWindow>public void mergeWindows(WindowingFn.MergeContext c) throws java.lang.Exception
WindowingFn See MergeOverlappingIntervalWindows.mergeWindows(com.google.cloud.dataflow.sdk.transforms.windowing.WindowingFn<?, com.google.cloud.dataflow.sdk.transforms.windowing.IntervalWindow>.MergeContext) for an
example of how to override this method.
mergeWindows in class WindowingFn<java.lang.Object,IntervalWindow>java.lang.Exceptionpublic Coder<IntervalWindow> windowCoder()
WindowingFnCoder used for serializing the windows used
by this windowingFn.windowCoder in class WindowingFn<java.lang.Object,IntervalWindow>public boolean isCompatible(WindowingFn<?,?> other)
WindowingFnWindowingFn.isCompatible in class WindowingFn<java.lang.Object,IntervalWindow>