pyflink.datastream.functions.CoProcessFunction#
- class CoProcessFunction[source]#
A function that processes elements of two streams and produces a single output one.
The function will be called for every element in the input streams and can produce zero or more output elements. Contrary to the
CoFlatMapFunction
, this function can also query the time (both event and processing) and set timers, through the providedCoProcessFunction.Context
. When reacting to the firing of set timers the function can emit yet more elements.An example use-case for connected streams would be the application of a set of rules that change over time ({@code stream A}) to the elements contained in another stream (stream {@code B}). The rules contained in {@code stream A} can be stored in the state and wait for new elements to arrive on {@code stream B}. Upon reception of a new element on {@code stream B}, the function can now apply the previously stored rules to the element and directly emit a result, and/or register a timer that will trigger an action in the future.
Methods
close
()open
(runtime_context)process_element1
(value, ctx)This method is called for each element in the first of the connected streams.
process_element2
(value, ctx)This method is called for each element in the second of the connected streams.