public class FixedWindows extends PartitioningWindowFn<java.lang.Object,IntervalWindow>
WindowFn
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))));
WindowFn.AssignContext, WindowFn.MergeContext
Modifier and Type | Method and Description |
---|---|
IntervalWindow |
assignWindow(Instant timestamp)
Returns the single window to which elements with this timestamp belong.
|
boolean |
equals(java.lang.Object object) |
Duration |
getOffset() |
Duration |
getSize() |
int |
hashCode() |
boolean |
isCompatible(WindowFn<?,?> other)
Returns whether this performs the same merging as the given
WindowFn . |
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 the
Coder 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.
|
assignWindows, getDefaultWindowMappingFn, getOutputTime
isNonMerging, mergeWindows
getWindowTypeDescriptor
public static FixedWindows of(Duration size)
public FixedWindows withOffset(Duration offset)
java.lang.IllegalArgumentException
- if offset is not in [0, size)public IntervalWindow assignWindow(Instant timestamp)
PartitioningWindowFn
assignWindow
in class PartitioningWindowFn<java.lang.Object,IntervalWindow>
public void populateDisplayData(DisplayData.Builder builder)
WindowFn
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.
populateDisplayData
in interface HasDisplayData
populateDisplayData
in class WindowFn<java.lang.Object,IntervalWindow>
builder
- The builder to populate with display data.HasDisplayData
public Coder<IntervalWindow> windowCoder()
WindowFn
Coder
used for serializing the windows used
by this windowFn.windowCoder
in class WindowFn<java.lang.Object,IntervalWindow>
public boolean isCompatible(WindowFn<?,?> other)
WindowFn
WindowFn
.isCompatible
in class WindowFn<java.lang.Object,IntervalWindow>
public Duration getSize()
public Duration getOffset()
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object