Hi, No there is no API in the operator to know which mode it works in. We aim to have separate operators for both modes if required. You can check e.g. how we do it in KeyedBroadcastStateTransformationTranslator[1].
Yes, it should be possible to register a timer for Long.MAX_WATERMARK if you want to apply a transformation at the end of each key. You could also use the reduce operation (DataStream#keyBy#reduce) in BATCH mode. A side note, I don't fully get what you mean by "build state for our streaming application". Bear in mind though you cannot take a savepoint from a job running in the BATCH execution mode. Moreover it uses a different kind of StateBackend. Actually a dummy one, which just imitates a real state backend. Best, Dawid [1] https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/translators/KeyedBroadcastStateTransformationTranslator.java On 25/05/2021 17:04, ChangZhuo Chen (陳昌倬) wrote: > Hi, > > Currently, we want to use batch execution mode [0] and historical data > to build state for our streaming application. Due to different between > batch & streaming mode, we want to check current execution mode in > custom operator. So our question is: > > > * Is there any API for custom operator to know current execution mode > (batch or streaming)? > > * If we want to output after all elements of one specific key are > processed, can we just use timer since timer is triggered at the end > of input [0]? > > > [0] > https://ci.apache.org/projects/flink/flink-docs-release-1.13/docs/dev/datastream/execution_mode/ >
OpenPGP_signature
Description: OpenPGP digital signature