Class WindowFnTestUtils
WindowFns.-
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 theWindowFnover 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 theWindowFnover 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 providedWindowFnandTimestampCombiner.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 providedWindowFnandTimestampCombiner.
-
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 theWindowFnover 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 theWindowFnover the provided input, returning a map of windows to the timestamps in those windows. This version allows to pass a list ofTimestampedValuein 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 aTimestampedValuein 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 providedWindowFnandTimestampCombiner.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 providedWindowFnandTimestampCombiner.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
TimestampedValuein case the value is needed to assign windows.- Throws:
Exception
-