This is an automated email from the ASF dual-hosted git repository. guoweijie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/flink.git
commit 3c77ccca55016461f0f927440fbe6cef4a654471 Author: Jeyhun Karimov <[email protected]> AuthorDate: Thu May 30 18:22:54 2024 +0200 [FLINK-34977][API] Add useStates to the ProcessFunction --- .../flink/datastream/api/function/ProcessFunction.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/flink-datastream-api/src/main/java/org/apache/flink/datastream/api/function/ProcessFunction.java b/flink-datastream-api/src/main/java/org/apache/flink/datastream/api/function/ProcessFunction.java index 2efee819aff..9721aba35ec 100644 --- a/flink-datastream-api/src/main/java/org/apache/flink/datastream/api/function/ProcessFunction.java +++ b/flink-datastream-api/src/main/java/org/apache/flink/datastream/api/function/ProcessFunction.java @@ -20,6 +20,10 @@ package org.apache.flink.datastream.api.function; import org.apache.flink.annotation.Experimental; import org.apache.flink.api.common.functions.Function; +import org.apache.flink.api.common.state.StateDeclaration; + +import java.util.Collections; +import java.util.Set; /** Base class for all user defined process functions. */ @Experimental @@ -36,6 +40,16 @@ public interface ProcessFunction extends Function { */ default void open() throws Exception {} + /** + * Explicitly declares states upfront. Each specific state must be declared in this method + * before it can be used. + * + * @return all declared states used by this process function. + */ + default Set<StateDeclaration> usesStates() { + return Collections.emptySet(); + } + /** * Tear-down method for the user code. It is called after the last call to the main working * methods (e.g. processRecord).
