Class KeyedStateReaderFunction<K,OUT>
- java.lang.Object
-
- org.apache.flink.api.common.functions.AbstractRichFunction
-
- org.apache.flink.state.api.functions.KeyedStateReaderFunction<K,OUT>
-
- Type Parameters:
K- Type of the keysOUT- Type of the output elements.
- All Implemented Interfaces:
Serializable,org.apache.flink.api.common.functions.Function,org.apache.flink.api.common.functions.RichFunction
@PublicEvolving public abstract class KeyedStateReaderFunction<K,OUT> extends org.apache.flink.api.common.functions.AbstractRichFunctionA function that processes keys from a restored operatorFor every key
readKey(Object, Context, Collector)is invoked. This can produce zero or more elements as output.NOTE: State descriptors must be eagerly registered in
open(Configuration). Any attempt to dynamically register states inside ofreadKeywill result in aRuntimeException.NOTE: A
KeyedStateReaderFunctionis always aRichFunction. Therefore, access to theRuntimeContextis always available and setup and teardown methods can be implemented. SeeRichFunction.open(OpenContext)andRichFunction.close().- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceKeyedStateReaderFunction.ContextContext thatKeyedStateReaderFunction's can use for getting additional data about an input record.
-
Constructor Summary
Constructors Constructor Description KeyedStateReaderFunction()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract voidopen(org.apache.flink.configuration.Configuration parameters)Initialization method for the function.abstract voidreadKey(K key, KeyedStateReaderFunction.Context ctx, org.apache.flink.util.Collector<OUT> out)Process one key from the restored state backend.-
Methods inherited from class org.apache.flink.api.common.functions.AbstractRichFunction
close, getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
-
-
-
-
Method Detail
-
open
public abstract void open(org.apache.flink.configuration.Configuration parameters) throws ExceptionInitialization method for the function. It is called beforereadKey(Object, Context, Collector)and thus suitable for one time setup work.This is the only method that my register state descriptors within a
KeyedStateReaderFunction.- Specified by:
openin interfaceorg.apache.flink.api.common.functions.RichFunction- Overrides:
openin classorg.apache.flink.api.common.functions.AbstractRichFunction- Throws:
Exception
-
readKey
public abstract void readKey(K key, KeyedStateReaderFunction.Context ctx, org.apache.flink.util.Collector<OUT> out) throws Exception
Process one key from the restored state backend.This function can read partitioned state from the restored state backend and output zero or more elements using the
Collectorparameter.- Parameters:
key- The input value.out- The collector for returning result values.- Throws:
Exception- This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.
-
-