Class WindowFnTestUtils
- java.lang.Object
-
- org.apache.beam.sdk.testing.WindowFnTestUtils
-
public class WindowFnTestUtils extends java.lang.Object
A utility class for testingWindowFn
s.
-
-
Constructor Summary
Constructors Constructor Description WindowFnTestUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,W extends BoundedWindow>
java.util.Collection<W>assignedWindows(WindowFn<T,W> windowFn, long timestamp)
static <T,W extends BoundedWindow>
java.util.Collection<W>assignedWindowsWithValue(WindowFn<T,W> windowFn, TimestampedValue<T> timestampedValue)
static <T,W extends BoundedWindow>
java.util.Map<W,java.util.Set<java.lang.String>>runWindowFn(WindowFn<T,W> windowFn, java.util.List<java.lang.Long> timestamps)
Runs theWindowFn
over the provided input, returning a map of windows to the timestamps in those windows.static <T,W extends BoundedWindow>
java.util.Map<W,java.util.Set<java.lang.String>>runWindowFnWithValue(WindowFn<T,W> windowFn, java.util.List<TimestampedValue<T>> timestampedValues)
Runs theWindowFn
over the provided input, returning a map of windows to the timestamps in those windows.static java.util.Set<java.lang.String>
set(long... timestamps)
Creates a Set of elements to be used as expected output inrunWindowFn(org.apache.beam.sdk.transforms.windowing.WindowFn<T, W>, java.util.List<java.lang.Long>)
.static <T,W extends IntervalWindow>
voidvalidateGetOutputTimestamps(WindowFn<T,W> windowFn, TimestampCombiner timestampCombiner, java.util.List<java.util.List<java.lang.Long>> timestampsPerWindow)
Verifies that later-ending merged windows from any of the timestamps hold up output of earlier-ending windows, using the providedWindowFn
andTimestampCombiner
.static <T,W extends IntervalWindow>
voidvalidateGetOutputTimestampsWithValue(WindowFn<T,W> windowFn, TimestampCombiner timestampCombiner, java.util.List<java.util.List<TimestampedValue<T>>> timestampValuesPerWindow)
Verifies that later-ending merged windows from any of the timestampValues hold up output of earlier-ending windows, using the providedWindowFn
andTimestampCombiner
.
-
-
-
Method Detail
-
set
public static java.util.Set<java.lang.String> set(long... timestamps)
Creates a Set of elements to be used as expected output inrunWindowFn(org.apache.beam.sdk.transforms.windowing.WindowFn<T, W>, java.util.List<java.lang.Long>)
.
-
runWindowFn
public static <T,W extends BoundedWindow> java.util.Map<W,java.util.Set<java.lang.String>> runWindowFn(WindowFn<T,W> windowFn, java.util.List<java.lang.Long> timestamps) throws java.lang.Exception
Runs theWindowFn
over the provided input, returning a map of windows to the timestamps in those windows.- Throws:
java.lang.Exception
-
runWindowFnWithValue
public static <T,W extends BoundedWindow> java.util.Map<W,java.util.Set<java.lang.String>> runWindowFnWithValue(WindowFn<T,W> windowFn, java.util.List<TimestampedValue<T>> timestampedValues) throws java.lang.Exception
Runs theWindowFn
over the provided input, returning a map of windows to the timestamps in those windows. This version allows to pass a list ofTimestampedValue
in case the values are used to assign windows.- Throws:
java.lang.Exception
-
assignedWindows
public static <T,W extends BoundedWindow> java.util.Collection<W> assignedWindows(WindowFn<T,W> windowFn, long timestamp) throws java.lang.Exception
- Throws:
java.lang.Exception
-
assignedWindowsWithValue
public static <T,W extends BoundedWindow> java.util.Collection<W> assignedWindowsWithValue(WindowFn<T,W> windowFn, TimestampedValue<T> timestampedValue) throws java.lang.Exception
runsWindowFn.assignWindows(WindowFn.AssignContext)
. This version allows passing aTimestampedValue
in case the value is needed to assign windows.- Throws:
java.lang.Exception
-
validateGetOutputTimestamps
public static <T,W extends IntervalWindow> void validateGetOutputTimestamps(WindowFn<T,W> windowFn, TimestampCombiner timestampCombiner, java.util.List<java.util.List<java.lang.Long>> timestampsPerWindow) throws java.lang.Exception
Verifies that later-ending merged windows from any of the timestamps hold up output of earlier-ending windows, using the providedWindowFn
andTimestampCombiner
.Given a list of lists of timestamps, where each list is expected to merge into a single window with end times in ascending order, assigns and merges windows for each list (as though each were a separate key/user session). Then combines each timestamp in the list according to the provided
TimestampCombiner
.Verifies that a overlapping windows do not hold each other up via the watermark.
- Throws:
java.lang.Exception
-
validateGetOutputTimestampsWithValue
public static <T,W extends IntervalWindow> void validateGetOutputTimestampsWithValue(WindowFn<T,W> windowFn, TimestampCombiner timestampCombiner, java.util.List<java.util.List<TimestampedValue<T>>> timestampValuesPerWindow) throws java.lang.Exception
Verifies that later-ending merged windows from any of the timestampValues hold up output of earlier-ending windows, using the providedWindowFn
andTimestampCombiner
.Given a list of lists of timestampValues, where each list is expected to merge into a single window with end times in ascending order, assigns and merges windows for each list (as though each were a separate key/user session). Then combines each timestamp in the list according to the provided
TimestampCombiner
.Verifies that a overlapping windows do not hold each other up via the watermark. This version allows passing
TimestampedValue
in case the value is needed to assign windows.- Throws:
java.lang.Exception
-
-