Google Cloud Dataflow SDK for Java, version 1.9.1
Class FixedWindows
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.transforms.windowing.WindowFn<T,W>
-
- com.google.cloud.dataflow.sdk.transforms.windowing.NonMergingWindowFn<T,W>
-
- com.google.cloud.dataflow.sdk.transforms.windowing.PartitioningWindowFn<Object,IntervalWindow>
-
- com.google.cloud.dataflow.sdk.transforms.windowing.FixedWindows
-
- All Implemented Interfaces:
- HasDisplayData, Serializable
public class FixedWindows extends PartitioningWindowFn<Object,IntervalWindow>
AWindowFn
that windows values into fixed-size timestamp-based windows.For example, in order to partition the data into 10 minute windows:
PCollection<Integer> items = ...; PCollection<Integer> windowedItems = items.apply( Window.<Integer>into(FixedWindows.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 Modifier and Type Method and Description IntervalWindow
assignWindow(Instant timestamp)
Returns the single window to which elements with this timestamp belong.boolean
equals(Object object)
Duration
getOffset()
Duration
getSize()
int
hashCode()
boolean
isCompatible(WindowFn<?,?> other)
Returns whether this performs the same merging as the givenWindowFn
.static FixedWindows
of(Duration size)
Partitions the timestamp space into half-open intervals of the form [N * size, (N + 1) * size), where 0 is the epoch.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.FixedWindows
withOffset(Duration offset)
Partitions the timestamp space into half-open intervals of the form [N * size + offset, (N + 1) * size + offset), where 0 is the epoch.-
Methods inherited from class com.google.cloud.dataflow.sdk.transforms.windowing.PartitioningWindowFn
assignsToSingleWindow, assignWindows, getOutputTime, getSideInputWindow
-
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
getOutputTimeFn
-
-
-
-
Method Detail
-
of
public static FixedWindows of(Duration size)
Partitions the timestamp space into half-open intervals of the form [N * size, (N + 1) * size), where 0 is the epoch.
-
withOffset
public FixedWindows withOffset(Duration offset)
Partitions the timestamp space into half-open intervals of the form [N * size + offset, (N + 1) * size + offset), where 0 is the epoch.- Throws:
IllegalArgumentException
- if offset is not in [0, size)
-
assignWindow
public IntervalWindow assignWindow(Instant timestamp)
Description copied from class:PartitioningWindowFn
Returns the single window to which elements with this timestamp belong.- Specified by:
assignWindow
in classPartitioningWindowFn<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 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
-
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>
-
getSize
public Duration getSize()
-
getOffset
public Duration getOffset()
-
-