public class SlidingWindows extends NonMergingWindowFn<Object,IntervalWindow>
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))));
WindowFn.AssignContext, WindowFn.MergeContext| Modifier and Type | Method and Description |
|---|---|
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.
|
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).
|
isNonMerging, mergeWindowsassignsToSingleWindow, getOutputTimepublic static SlidingWindows of(Duration size)
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.
public SlidingWindows every(Duration period)
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.public SlidingWindows withOffset(Duration offset)
IllegalArgumentException - if offset is not in [0, period)public Coder<IntervalWindow> windowCoder()
WindowFnCoder used for serializing the windows used
by this windowFn.windowCoder in class WindowFn<Object,IntervalWindow>public Collection<IntervalWindow> assignWindows(WindowFn.AssignContext c)
WindowFnassignWindows in class WindowFn<Object,IntervalWindow>public IntervalWindow getSideInputWindow(BoundedWindow window)
getSideInputWindow in class WindowFn<Object,IntervalWindow>public boolean isCompatible(WindowFn<?,?> other)
WindowFnWindowFn.isCompatible in class WindowFn<Object,IntervalWindow>public Duration getPeriod()
public Duration getSize()
public Duration getOffset()
@Experimental(value=OUTPUT_TIME) public OutputTimeFn<? super IntervalWindow> getOutputTimeFn()
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.
getOutputTimeFn in class WindowFn<Object,IntervalWindow>