Hi Marc, I think you can just use keyed state in a CheckpointedFunction. FunctionInitializationContext gives you access to both keyed state and operator state (your stream needs to be keyed, of course). So you could just update your local custom state on regular invocations and update keyed state on calls to snapshotState. Check out the example in [1] where both types of state are used.
Does that help? Not sure if I understood the problem correctly. Best regards, Nico [1] https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/checkpoint/CheckpointedFunction.java#L74-L110 On Tue, Oct 5, 2021 at 3:28 PM Marc LEGER <maleger...@gmail.com> wrote: > Hello, > > Is there any method available in a RichFunction to be called by Flink with > a keyed context each time a checkpoint is triggered please ? > > It seems that the CheckpointedFunction interface provides such a feature > (snapshotState method) but only in case of operator state and it is called > in a non-keyed context. > > Indeed, I am implementing a CoFlatMapFunction with: > - a keyed state (state1) for a "control" stream (stream1) which is not > often updated, > - a keyed state (state2) for a "data" stream (stream2) with a high > throughput and relying on a custom solution for internal state snapshot > with some potential performance impact. > > Consequently, I don't want to trigger a state2 update for every event > received in stream2 for efficiency reasons but rather update state2 based > on checkpoints triggered by Flink. > > Best Regards, > Marc > >