Class WindowFnTestUtils
WindowFn
s.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
W extends BoundedWindow>
Collection<W> assignedWindows
(WindowFn<T, W> windowFn, long timestamp) static <T,
W extends BoundedWindow>
Collection<W> assignedWindowsWithValue
(WindowFn<T, W> windowFn, TimestampedValue<T> timestampedValue) static <T,
W extends BoundedWindow>
Map<W, Set<String>> runWindowFn
(WindowFn<T, W> windowFn, List<Long> timestamps) Runs theWindowFn
over the provided input, returning a map of windows to the timestamps in those windows.static <T,
W extends BoundedWindow>
Map<W, Set<String>> runWindowFnWithValue
(WindowFn<T, W> windowFn, List<TimestampedValue<T>> timestampedValues) Runs theWindowFn
over the provided input, returning a map of windows to the timestamps in those windows.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, List<List<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, List<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
.
-
Constructor Details
-
WindowFnTestUtils
public WindowFnTestUtils()
-
-
Method Details
-
set
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> Map<W,Set<String>> runWindowFn(WindowFn<T, W> windowFn, List<Long> timestamps) throws ExceptionRuns theWindowFn
over the provided input, returning a map of windows to the timestamps in those windows.- Throws:
Exception
-
runWindowFnWithValue
public static <T,W extends BoundedWindow> Map<W,Set<String>> runWindowFnWithValue(WindowFn<T, W> windowFn, List<TimestampedValue<T>> timestampedValues) throws ExceptionRuns 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:
Exception
-
assignedWindows
public static <T,W extends BoundedWindow> Collection<W> assignedWindows(WindowFn<T, W> windowFn, long timestamp) throws Exception- Throws:
Exception
-
assignedWindowsWithValue
public static <T,W extends BoundedWindow> Collection<W> assignedWindowsWithValue(WindowFn<T, W> windowFn, TimestampedValue<T> timestampedValue) throws ExceptionrunsWindowFn.assignWindows(WindowFn.AssignContext)
. This version allows passing aTimestampedValue
in case the value is needed to assign windows.- Throws:
Exception
-
validateGetOutputTimestamps
public static <T,W extends IntervalWindow> void validateGetOutputTimestamps(WindowFn<T, W> windowFn, TimestampCombiner timestampCombiner, List<List<Long>> timestampsPerWindow) throws ExceptionVerifies 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:
Exception
-
validateGetOutputTimestampsWithValue
public static <T,W extends IntervalWindow> void validateGetOutputTimestampsWithValue(WindowFn<T, W> windowFn, TimestampCombiner timestampCombiner, List<List<TimestampedValue<T>>> timestampValuesPerWindow) throws ExceptionVerifies 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:
Exception
-