com.google.cloud.dataflow.sdk.transforms.windowing

## 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>

A `WindowFn` windowing values into sessions separated by `gapDuration`-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
`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 for `WindowingStrategy.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 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.

### Methods inherited from class com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn

`assignsToSingleWindow, getOutputTime, isNonMerging`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### withGapDuration

    public static Sessions withGapDuration(Duration gapDuration)

Creates a `Sessions` `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 class `WindowFn<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 class `WindowFn<Object,IntervalWindow>`
Throws:
  `Exception`

#### windowCoder

    public Coder<IntervalWindow> windowCoder()

Description copied from class: `WindowFn`
Returns the `Coder` used for serializing the windows used by this windowFn.

Specified by:
  `windowCoder` in class `WindowFn<Object,IntervalWindow>`

#### isCompatible

    public boolean isCompatible(WindowFn<?,?> other)

Description copied from class: `WindowFn`
Returns whether this performs the same merging as the given `WindowFn`.

Specified by:
  `isCompatible` in class `WindowFn<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 class `WindowFn<Object,IntervalWindow>`

#### getOutputTimeFn

    @Experimental(value=OUTPUT_TIME)
    public OutputTimeFn<? super IntervalWindow> getOutputTimeFn()

Description copied from class: `WindowFn`
Provides a default implementation for `WindowingStrategy.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 in `OutputTimeFn.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 class `WindowFn<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 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.

Specified by:
  `populateDisplayData` in interface `HasDisplayData`
Overrides:
  `populateDisplayData` in class `WindowFn<Object,IntervalWindow>`
Parameters:
  `builder` - The builder to populate with display data.
See Also:
  `HasDisplayData`

#### equals

    public boolean equals(Object object)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`