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() |
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.
|
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. |
getOutputTime, getWindowTypeDescriptor, isNonMerging
public static Sessions withGapDuration(Duration gapDuration)
Sessions
WindowFn
with the specified gap duration.public java.util.Collection<IntervalWindow> assignWindows(WindowFn.AssignContext c)
WindowFn
assignWindows
in class WindowFn<java.lang.Object,IntervalWindow>
public void mergeWindows(WindowFn.MergeContext c) throws java.lang.Exception
WindowFn
See 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.Exception
public Coder<IntervalWindow> windowCoder()
WindowFn
Coder
used for serializing the windows used
by this windowFn.windowCoder
in class WindowFn<java.lang.Object,IntervalWindow>
public boolean isCompatible(WindowFn<?,?> other)
WindowFn
WindowFn
.isCompatible
in class WindowFn<java.lang.Object,IntervalWindow>
public WindowMappingFn<IntervalWindow> getDefaultWindowMappingFn()
WindowFn
WindowMappingFn
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)
WindowFn
populateDisplayData(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 HasDisplayData
populateDisplayData
in class WindowFn<java.lang.Object,IntervalWindow>
builder
- The builder to populate with display data.HasDisplayData
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object