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

## Class SlidingWindows

- java.lang.Object
- - com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn<T,W>
  - - com.google.cloud.dataflow.sdk.transforms.windowing.NonMergingWindowFn<Object,IntervalWindow>
    - - com.google.cloud.dataflow.sdk.transforms.windowing.SlidingWindows

All Implemented Interfaces:
  HasDisplayData, Serializable

    public class SlidingWindows
    extends NonMergingWindowFn<Object,IntervalWindow>

A `WindowFn` that windows values into possibly overlapping fixed-size timestamp-based windows.

For example, in order to window data into 10 minute windows that update every minute:

     PCollection<Integer> items = ...;
     PCollection<Integer> windowedItems = items.apply(
       Window.<Integer>into(SlidingWindows.of(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)`
`SlidingWindows` `every(Duration period)` Returns a new `SlidingWindows` with the original size, that assigns timestamps into half-open intervals of the form [N * period, N * period + size), where 0 is the epoch.
`Duration` `getOffset()`
`OutputTimeFn<? super IntervalWindow>` `getOutputTimeFn()` Ensures that later sliding windows have an output time that is past the end of earlier windows.
`Duration` `getPeriod()`
`IntervalWindow` `getSideInputWindow(BoundedWindow window)` Return the earliest window that contains the end of the main-input window.
`Duration` `getSize()`
`int` `hashCode()`
`boolean` `isCompatible(WindowFn<?,?> other)` Returns whether this performs the same merging as the given `WindowFn`.
`static SlidingWindows` `of(Duration size)` Assigns timestamps into half-open intervals of the form [N * period, N * period + size), where 0 is the epoch.
`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.
`SlidingWindows` `withOffset(Duration offset)` Assigns timestamps into half-open intervals of the form [N * period + offset, N * period + offset + size).

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

`isNonMerging, mergeWindows`

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

`assignsToSingleWindow, getOutputTime`

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

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

### Method Detail

#### of

    public static SlidingWindows of(Duration size)

Assigns timestamps into half-open intervals of the form [N * period, N * period + size), where 0 is the epoch.

If `every(org.joda.time.Duration)` is not called, the period defaults to the largest time unit smaller than the given duration. For example, specifying a size of 5 seconds will result in a default period of 1 second.

#### every

    public SlidingWindows every(Duration period)

Returns a new `SlidingWindows` with the original size, that assigns timestamps into half-open intervals of the form [N * period, N * period + size), where 0 is the epoch.

#### withOffset

    public SlidingWindows withOffset(Duration offset)

Assigns timestamps into half-open intervals of the form [N * period + offset, N * period + offset + size).

Throws:
  `IllegalArgumentException` - if offset is not in [0, period)

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

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

#### getSideInputWindow

    public IntervalWindow getSideInputWindow(BoundedWindow window)

Return the earliest window that contains the end of the main-input window.

Specified by:
  `getSideInputWindow` 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>`

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

#### getPeriod

    public Duration getPeriod()

#### getSize

    public Duration getSize()

#### getOffset

    public Duration getOffset()

#### getOutputTimeFn

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

Ensures that later sliding windows have an output time that is past the end of earlier windows.

If this is the earliest sliding window containing `inputTimestamp`, that's fine. Otherwise, we pick the earliest time that doesn't overlap with earlier windows.

Overrides:
  `getOutputTimeFn` in class `WindowFn<Object,IntervalWindow>`

#### equals

    public boolean equals(Object object)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`