Class Sessions
- java.lang.Object
-
- org.apache.beam.sdk.transforms.windowing.WindowFn<java.lang.Object,IntervalWindow>
-
- org.apache.beam.sdk.transforms.windowing.Sessions
-
- All Implemented Interfaces:
java.io.Serializable
,HasDisplayData
public class Sessions extends WindowFn<java.lang.Object,IntervalWindow>
AWindowFn
that windows values into sessions separated by periods with no input for at least the duration specified bygetGapDuration()
.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))));
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.beam.sdk.transforms.windowing.WindowFn
WindowFn.AssignContext, WindowFn.MergeContext
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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(@Nullable java.lang.Object object)
WindowMappingFn<IntervalWindow>
getDefaultWindowMappingFn()
Returns the defaultWindowMappingFn
to use to map main input windows to side input windows.org.joda.time.Duration
getGapDuration()
TypeDescriptor<IntervalWindow>
getWindowTypeDescriptor()
Returns aTypeDescriptor
capturing what is known statically about the window type of thisWindowFn
instance's most-derived class.int
hashCode()
boolean
isCompatible(WindowFn<?,?> other)
Returns whether this performs the same merging as the givenWindowFn
.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)
ThrowIncompatibleWindowException
if this WindowFn does not perform the same merging as the given $WindowFn
.Coder<IntervalWindow>
windowCoder()
Returns theCoder
used for serializing the windows used by this windowFn.static Sessions
withGapDuration(org.joda.time.Duration gapDuration)
Creates aSessions
WindowFn
with the specified gap duration.-
Methods inherited from class org.apache.beam.sdk.transforms.windowing.WindowFn
assignsToOneWindow, isNonMerging
-
-
-
-
Method Detail
-
withGapDuration
public static Sessions withGapDuration(org.joda.time.Duration gapDuration)
Creates aSessions
WindowFn
with the specified gap duration.
-
assignWindows
public java.util.Collection<IntervalWindow> assignWindows(WindowFn.AssignContext c)
Description copied from class:WindowFn
Given a timestamp and element, returns the set of windows into which it should be placed.- Specified by:
assignWindows
in classWindowFn<java.lang.Object,IntervalWindow>
-
mergeWindows
public void mergeWindows(WindowFn.MergeContext c) throws java.lang.Exception
Description copied from class:WindowFn
Does whatever merging of windows is necessary.See
MergeOverlappingIntervalWindows.mergeWindows(org.apache.beam.sdk.transforms.windowing.WindowFn.MergeContext)
for an example of how to override this method.- Specified by:
mergeWindows
in classWindowFn<java.lang.Object,IntervalWindow>
- Throws:
java.lang.Exception
-
windowCoder
public Coder<IntervalWindow> windowCoder()
Description copied from class:WindowFn
Returns theCoder
used for serializing the windows used by this windowFn.- Specified by:
windowCoder
in classWindowFn<java.lang.Object,IntervalWindow>
-
isCompatible
public boolean isCompatible(WindowFn<?,?> other)
Description copied from class:WindowFn
Returns whether this performs the same merging as the givenWindowFn
.- Specified by:
isCompatible
in classWindowFn<java.lang.Object,IntervalWindow>
-
verifyCompatibility
public void verifyCompatibility(WindowFn<?,?> other) throws IncompatibleWindowException
Description copied from class:WindowFn
ThrowIncompatibleWindowException
if this WindowFn does not perform the same merging as the given $WindowFn
.- Overrides:
verifyCompatibility
in classWindowFn<java.lang.Object,IntervalWindow>
- Throws:
IncompatibleWindowException
- if compared WindowFns are not compatible.
-
getWindowTypeDescriptor
public TypeDescriptor<IntervalWindow> getWindowTypeDescriptor()
Description copied from class:WindowFn
Returns aTypeDescriptor
capturing what is known statically about the window type of thisWindowFn
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.- Overrides:
getWindowTypeDescriptor
in classWindowFn<java.lang.Object,IntervalWindow>
-
getDefaultWindowMappingFn
public WindowMappingFn<IntervalWindow> getDefaultWindowMappingFn()
Description copied from class:WindowFn
Returns the defaultWindowMappingFn
to use to map main input windows to side input windows. This should accept arbitrary main input windows, and produce aBoundedWindow
that can be produced by thisWindowFn
.- Specified by:
getDefaultWindowMappingFn
in classWindowFn<java.lang.Object,IntervalWindow>
-
getGapDuration
public org.joda.time.Duration getGapDuration()
-
populateDisplayData
public void populateDisplayData(DisplayData.Builder builder)
Description copied from class:WindowFn
Register display data for the given transform or component.populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect display data viaDisplayData.from(HasDisplayData)
. Implementations may callsuper.populateDisplayData(builder)
in order to register display data in the current namespace, but should otherwise usesubcomponent.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.
- Specified by:
populateDisplayData
in interfaceHasDisplayData
- Overrides:
populateDisplayData
in classWindowFn<java.lang.Object,IntervalWindow>
- Parameters:
builder
- The builder to populate with display data.- See Also:
HasDisplayData
-
equals
public boolean equals(@Nullable java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-