T - type of elements being windowedW - BoundedWindow subclass used to represent the
windows used by this WindowFnpublic abstract class WindowFn<T,W extends BoundedWindow>
extends java.lang.Object
implements java.io.Serializable
Window transform used to assign elements into
windows and to determine how windows are merged. See Window for more
information on how WindowFns are used and for a library of
predefined WindowFns.
Users will generally want to use the predefined
WindowFns, but it is also possible to create new
subclasses.
TODO: Describe how to properly create WindowFns.
| Modifier and Type | Class and Description |
|---|---|
class |
WindowFn.AssignContext
Information available when running
assignWindows(com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn<T, W>.AssignContext). |
class |
WindowFn.MergeContext
Information available when running
mergeWindows(com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn<T, W>.MergeContext). |
| Constructor and Description |
|---|
WindowFn() |
| Modifier and Type | Method and Description |
|---|---|
abstract java.util.Collection<W> |
assignWindows(WindowFn.AssignContext c)
Given a timestamp and element, returns the set of windows into which it
should be placed.
|
W |
getSideInputWindow(BoundedWindow window)
Returns the window of the side input corresponding to the given window of
the main input.
|
abstract boolean |
isCompatible(WindowFn<?,?> other)
Returns whether this performs the same merging as the given
WindowFn. |
abstract void |
mergeWindows(WindowFn.MergeContext c)
Does whatever merging of windows is necessary.
|
abstract Coder<W> |
windowCoder()
Returns the
Coder used for serializing the windows used
by this windowFn. |
public abstract java.util.Collection<W> assignWindows(WindowFn.AssignContext c) throws java.lang.Exception
java.lang.Exceptionpublic abstract void mergeWindows(WindowFn.MergeContext c) throws java.lang.Exception
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.
java.lang.Exceptionpublic abstract boolean isCompatible(WindowFn<?,?> other)
WindowFn.public abstract Coder<W> windowCoder()
Coder used for serializing the windows used
by this windowFn.public W getSideInputWindow(BoundedWindow window)
For example, if both the main and side inputs are windowed by
FixedWindows, the side input corresponding to a particular main
input element will be the one in the same window as that element.
Authors of custom WindowFns should override this if that is not
the desired behavior for side inputs with their WindowFn.