@Internal public class IdentityWindowFn<T> extends NonMergingWindowFn<T,BoundedWindow>
WindowFn that leaves all associations between elements and windows unchanged.
This WindowFn is applied when elements must be passed through a GroupByKey,
but should maintain their existing Window assignments. Because windows may have been
merged, the earlier WindowFn may not appropriately maintain the existing window
assignments. For example, if the earlier WindowFn merges windows, after a GroupByKey the WindowingStrategy uses InvalidWindows, and no further GroupByKey can be applied without applying a new WindowFn. This WindowFn allows
existing window assignments to be maintained across a single group by key, at which point the
earlier WindowingStrategy should be restored.
This WindowFn is an internal implementation detail of sdk-provided utilities, and
should not be used by Pipeline writers.
WindowFn.AssignContext, WindowFn.MergeContext| Constructor and Description |
|---|
IdentityWindowFn(Coder<? extends BoundedWindow> coder) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
assignsToOneWindow()
Returns true if this
WindowFn always assigns an element to exactly one window. |
java.util.Collection<BoundedWindow> |
assignWindows(WindowFn.AssignContext c)
Given a timestamp and element, returns the set of windows into which it should be placed.
|
WindowMappingFn<BoundedWindow> |
getDefaultWindowMappingFn()
Returns the default
WindowMappingFn to use to map main input windows to side input
windows. |
org.joda.time.Instant |
getOutputTime(org.joda.time.Instant inputTimestamp,
BoundedWindow window)
Returns the output timestamp to use for data depending on the given
inputTimestamp in
the specified window. |
boolean |
isCompatible(WindowFn<?,?> other)
Returns whether this performs the same merging as the given
WindowFn. |
void |
verifyCompatibility(WindowFn<?,?> other)
Throw
IncompatibleWindowException if this WindowFn does not perform the same merging as
the given $WindowFn. |
Coder<BoundedWindow> |
windowCoder()
Returns the
Coder used for serializing the windows used by this windowFn. |
isNonMerging, mergeWindowsgetWindowTypeDescriptor, populateDisplayDatapublic IdentityWindowFn(Coder<? extends BoundedWindow> coder)
public java.util.Collection<BoundedWindow> assignWindows(WindowFn.AssignContext c) throws java.lang.Exception
WindowFnassignWindows in class WindowFn<T,BoundedWindow>java.lang.Exceptionpublic boolean isCompatible(WindowFn<?,?> other)
WindowFnWindowFn.isCompatible in class WindowFn<T,BoundedWindow>public void verifyCompatibility(WindowFn<?,?> other) throws IncompatibleWindowException
WindowFnIncompatibleWindowException if this WindowFn does not perform the same merging as
the given $WindowFn.verifyCompatibility in class WindowFn<T,BoundedWindow>IncompatibleWindowException - if compared WindowFns are not compatible.public Coder<BoundedWindow> windowCoder()
WindowFnCoder used for serializing the windows used by this windowFn.windowCoder in class WindowFn<T,BoundedWindow>public WindowMappingFn<BoundedWindow> getDefaultWindowMappingFn()
WindowFnWindowMappingFn to use to map main input windows to side input
windows. This should accept arbitrary main input windows, and produce a BoundedWindow
that can be produced by this WindowFn.getDefaultWindowMappingFn in class WindowFn<T,BoundedWindow>public org.joda.time.Instant getOutputTime(org.joda.time.Instant inputTimestamp,
BoundedWindow window)
WindowFninputTimestamp in
the specified window.
The result of this method must be between inputTimestamp and window.maxTimestamp() (inclusive on both sides).
This function must be monotonic across input timestamps. Specifically, if A < B,
then getOutputTime(A, window) <= getOutputTime(B, window).
For a WindowFn that doesn't produce overlapping windows, this can (and typically
should) just return inputTimestamp. In the presence of overlapping windows, 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.
getOutputTime in class WindowFn<T,BoundedWindow>public boolean assignsToOneWindow()
WindowFnWindowFn always assigns an element to exactly one window.
If this varies per-element, or cannot be determined, conservatively return false.
By default, returns false.
assignsToOneWindow in class WindowFn<T,BoundedWindow>