public class Sessions extends WindowFn<java.lang.Object,IntervalWindow>
WindowFn that windows values into sessions separated by periods with no input for at
least the duration specified by getGapDuration().
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 |
|---|---|
java.util.Collection<IntervalWindow> |
assignWindows(WindowFn.AssignContext c)
Given a timestamp and element, returns the set of windows into which it should be placed.
|
boolean |
equals(java.lang.Object object) |
WindowMappingFn<IntervalWindow> |
getDefaultWindowMappingFn()
Returns the default
WindowMappingFn to use to map main input windows to side input
windows. |
Duration |
getGapDuration() |
TypeDescriptor<IntervalWindow> |
getWindowTypeDescriptor()
Returns a
TypeDescriptor capturing what is known statically about the window type of
this WindowFn instance's most-derived class. |
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.
|
void |
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.
|
void |
verifyCompatibility(WindowFn<?,?> other)
Throw
IncompatibleWindowException if this WindowFn does not perform the same merging as
the given $WindowFn. |
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. |
assignsToOneWindow, getOutputTime, isNonMergingpublic static Sessions withGapDuration(Duration gapDuration)
Sessions WindowFn with the specified gap duration.public java.util.Collection<IntervalWindow> assignWindows(WindowFn.AssignContext c)
WindowFnassignWindows in class WindowFn<java.lang.Object,IntervalWindow>public void mergeWindows(WindowFn.MergeContext c) throws java.lang.Exception
WindowFnSee MergeOverlappingIntervalWindows.mergeWindows(org.apache.beam.sdk.transforms.windowing.WindowFn<?, org.apache.beam.sdk.transforms.windowing.IntervalWindow>.MergeContext) for an example of how to override
this method.
mergeWindows in class WindowFn<java.lang.Object,IntervalWindow>java.lang.Exceptionpublic Coder<IntervalWindow> windowCoder()
WindowFnCoder used for serializing the windows used by this windowFn.windowCoder in class WindowFn<java.lang.Object,IntervalWindow>public boolean isCompatible(WindowFn<?,?> other)
WindowFnWindowFn.isCompatible in class WindowFn<java.lang.Object,IntervalWindow>public void verifyCompatibility(WindowFn<?,?> other) throws IncompatibleWindowException
WindowFnIncompatibleWindowException if this WindowFn does not perform the same merging as
the given $WindowFn.verifyCompatibility in class WindowFn<java.lang.Object,IntervalWindow>IncompatibleWindowException - if compared WindowFns are not compatible.public TypeDescriptor<IntervalWindow> getWindowTypeDescriptor()
WindowFnTypeDescriptor capturing what is known statically about the window type of
this WindowFn instance's most-derived class.
In the normal case of a concrete WindowFn subclass with no generic type parameters
of its own (including anonymous inner classes), this will be a complete non-generic type.
getWindowTypeDescriptor in class WindowFn<java.lang.Object,IntervalWindow>public WindowMappingFn<IntervalWindow> getDefaultWindowMappingFn()
WindowFnWindowMappingFn to use to map main input windows to side input
windows. This should accept arbitrary main input windows, and produce a BoundedWindow
that can be produced by this WindowFn.getDefaultWindowMappingFn in class WindowFn<java.lang.Object,IntervalWindow>public Duration getGapDuration()
public void populateDisplayData(DisplayData.Builder builder)
WindowFnpopulateDisplayData(DisplayData.Builder) is invoked by Pipeline runners to collect
display data via DisplayData.from(HasDisplayData). Implementations may call super.populateDisplayData(builder) in order to register display data in the current namespace,
but should otherwise use subcomponent.populateDisplayData(builder) to use the namespace
of the subcomponent.
By default, does not register any display data. Implementors may override this method to provide their own display data.
populateDisplayData in interface HasDisplayDatapopulateDisplayData in class WindowFn<java.lang.Object,IntervalWindow>builder - The builder to populate with display data.HasDisplayDatapublic boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object