Class Sessions
- All Implemented Interfaces:
Serializable,HasDisplayData
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))));
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.beam.sdk.transforms.windowing.WindowFn
WindowFn.AssignContext, WindowFn.MergeContext -
Method Summary
Modifier and TypeMethodDescriptionGiven a timestamp and element, returns the set of windows into which it should be placed.booleanReturns the defaultWindowMappingFnto use to map main input windows to side input windows.Returns aTypeDescriptorcapturing what is known statically about the window type of thisWindowFninstance's most-derived class.inthashCode()booleanisCompatible(WindowFn<?, ?> other) Returns whether this performs the same merging as the givenWindowFn.voidDoes whatever merging of windows is necessary.voidpopulateDisplayData(DisplayData.Builder builder) Register display data for the given transform or component.voidverifyCompatibility(WindowFn<?, ?> other) ThrowIncompatibleWindowExceptionif this WindowFn does not perform the same merging as the given $WindowFn.Returns theCoderused for serializing the windows used by this windowFn.static SessionswithGapDuration(Duration gapDuration) Creates aSessionsWindowFnwith the specified gap duration.Methods inherited from class org.apache.beam.sdk.transforms.windowing.WindowFn
assignsToOneWindow, isNonMerging
-
Method Details
-
withGapDuration
Creates aSessionsWindowFnwith the specified gap duration. -
assignWindows
Description copied from class:WindowFnGiven a timestamp and element, returns the set of windows into which it should be placed.- Specified by:
assignWindowsin classWindowFn<Object,IntervalWindow>
-
mergeWindows
Description copied from class:WindowFnDoes 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:
mergeWindowsin classWindowFn<Object,IntervalWindow> - Throws:
Exception
-
windowCoder
Description copied from class:WindowFnReturns theCoderused for serializing the windows used by this windowFn.- Specified by:
windowCoderin classWindowFn<Object,IntervalWindow>
-
isCompatible
Description copied from class:WindowFnReturns whether this performs the same merging as the givenWindowFn.- Specified by:
isCompatiblein classWindowFn<Object,IntervalWindow>
-
verifyCompatibility
Description copied from class:WindowFnThrowIncompatibleWindowExceptionif this WindowFn does not perform the same merging as the given $WindowFn.- Overrides:
verifyCompatibilityin classWindowFn<Object,IntervalWindow> - Throws:
IncompatibleWindowException- if compared WindowFns are not compatible.
-
getWindowTypeDescriptor
Description copied from class:WindowFnReturns aTypeDescriptorcapturing what is known statically about the window type of thisWindowFninstance's most-derived class.In the normal case of a concrete
WindowFnsubclass with no generic type parameters of its own (including anonymous inner classes), this will be a complete non-generic type.- Overrides:
getWindowTypeDescriptorin classWindowFn<Object,IntervalWindow>
-
getDefaultWindowMappingFn
Description copied from class:WindowFnReturns the defaultWindowMappingFnto use to map main input windows to side input windows. This should accept arbitrary main input windows, and produce aBoundedWindowthat can be produced by thisWindowFn.- Specified by:
getDefaultWindowMappingFnin classWindowFn<Object,IntervalWindow>
-
getGapDuration
-
populateDisplayData
Description copied from class:WindowFnRegister 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:
populateDisplayDatain interfaceHasDisplayData- Overrides:
populateDisplayDatain classWindowFn<Object,IntervalWindow> - Parameters:
builder- The builder to populate with display data.- See Also:
-
equals
-
hashCode
public int hashCode()
-