Google Cloud Dataflow SDK for Java, version 1.9.1
Class Sessions
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn<Object,IntervalWindow>
-
- com.google.cloud.dataflow.sdk.transforms.windowing.Sessions
-
- All Implemented Interfaces:
- HasDisplayData, Serializable
public class Sessions extends WindowFn<Object,IntervalWindow>
AWindowFn
windowing values into sessions separated bygapDuration
-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>into(Sessions.withGapDuration(Duration.standardMinutes(10))));
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn
WindowFn.AssignContext, WindowFn.MergeContext
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description Collection<IntervalWindow>
assignWindows(WindowFn.AssignContext c)
Given a timestamp and element, returns the set of windows into which it should be placed.boolean
equals(Object object)
Duration
getGapDuration()
OutputTimeFn<? super IntervalWindow>
getOutputTimeFn()
Provides a default implementation forWindowingStrategy.getOutputTimeFn()
.IntervalWindow
getSideInputWindow(BoundedWindow window)
Returns the window of the side input corresponding to the given window of the main input.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.Coder<IntervalWindow>
windowCoder()
Returns theCoder
used for serializing the windows used by this windowFn.static Sessions
withGapDuration(Duration gapDuration)
Creates aSessions
WindowFn
with the specified gap duration.-
Methods inherited from class com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn
assignsToSingleWindow, getOutputTime, isNonMerging
-
-
-
-
Method Detail
-
withGapDuration
public static Sessions withGapDuration(Duration gapDuration)
Creates aSessions
WindowFn
with the specified gap duration.
-
assignWindows
public 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<Object,IntervalWindow>
-
mergeWindows
public void mergeWindows(WindowFn.MergeContext c) throws Exception
Description copied from class:WindowFn
Does whatever merging of windows is necessary.See
MergeOverlappingIntervalWindows.mergeWindows(com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn<?, com.google.cloud.dataflow.sdk.transforms.windowing.IntervalWindow>.MergeContext)
for an example of how to override this method.- Specified by:
mergeWindows
in classWindowFn<Object,IntervalWindow>
- Throws:
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<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<Object,IntervalWindow>
-
getSideInputWindow
public IntervalWindow getSideInputWindow(BoundedWindow window)
Description copied from class:WindowFn
Returns the window of the side input corresponding to the given window of the main input.Authors of custom
WindowFn
s should override this.- Specified by:
getSideInputWindow
in classWindowFn<Object,IntervalWindow>
-
getOutputTimeFn
@Experimental(value=OUTPUT_TIME) public OutputTimeFn<? super IntervalWindow> getOutputTimeFn()
Description copied from class:WindowFn
Provides a default implementation forWindowingStrategy.getOutputTimeFn()
. See the full specification there.If this
WindowFn
doesn't produce overlapping windows, this need not (and probably should not) override any of the default implementations inOutputTimeFn.Defaults
.If this
WindowFn
does produce overlapping windows that can be predicted here, it is suggested that the result in later overlapping windows is past the end of earlier windows so that the later windows don't prevent the watermark from progressing past the end of the earlier window.For example, a timestamp in a sliding window should be moved past the beginning of the next sliding window. See
SlidingWindows.getOutputTimeFn()
.- Overrides:
getOutputTimeFn
in classWindowFn<Object,IntervalWindow>
-
getGapDuration
public 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<Object,IntervalWindow>
- Parameters:
builder
- The builder to populate with display data.- See Also:
HasDisplayData
-
-