Class ArtificialKeyedStateMapper<IN,OUT>
- java.lang.Object
-
- org.apache.flink.api.common.functions.AbstractRichFunction
-
- org.apache.flink.api.common.functions.RichMapFunction<IN,OUT>
-
- org.apache.flink.streaming.tests.artificialstate.ArtificialKeyedStateMapper<IN,OUT>
-
- All Implemented Interfaces:
Serializable
,Function
,MapFunction<IN,OUT>
,RichFunction
,CheckpointedFunction
public class ArtificialKeyedStateMapper<IN,OUT> extends RichMapFunction<IN,OUT> implements CheckpointedFunction
A generic, statefulMapFunction
that allows specifying what states to maintain based on a provided list ofArtificialStateBuilder
s.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ArtificialKeyedStateMapper(MapFunction<IN,OUT> mapFunction, List<ArtificialStateBuilder<IN>> artificialStateBuilders)
ArtificialKeyedStateMapper(MapFunction<IN,OUT> mapFunction, ArtificialStateBuilder<IN> artificialStateBuilders)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
initializeState(FunctionInitializationContext context)
This method is called when the parallel function instance is created during distributed execution.OUT
map(IN value)
The mapping method.void
snapshotState(FunctionSnapshotContext context)
This method is called when a snapshot for a checkpoint is requested.-
Methods inherited from class org.apache.flink.api.common.functions.AbstractRichFunction
close, getIterationRuntimeContext, getRuntimeContext, open, setRuntimeContext
-
-
-
-
Constructor Detail
-
ArtificialKeyedStateMapper
public ArtificialKeyedStateMapper(MapFunction<IN,OUT> mapFunction, ArtificialStateBuilder<IN> artificialStateBuilders)
-
ArtificialKeyedStateMapper
public ArtificialKeyedStateMapper(MapFunction<IN,OUT> mapFunction, List<ArtificialStateBuilder<IN>> artificialStateBuilders)
-
-
Method Detail
-
map
public OUT map(IN value) throws Exception
Description copied from interface:MapFunction
The mapping method. Takes an element from the input data set and transforms it into exactly one element.- Specified by:
map
in interfaceMapFunction<IN,OUT>
- Specified by:
map
in classRichMapFunction<IN,OUT>
- Parameters:
value
- The input value.- Returns:
- The transformed value
- Throws:
Exception
- This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.
-
snapshotState
public void snapshotState(FunctionSnapshotContext context) throws Exception
Description copied from interface:CheckpointedFunction
This method is called when a snapshot for a checkpoint is requested. This acts as a hook to the function to ensure that all state is exposed by means previously offered throughFunctionInitializationContext
when the Function was initialized, or offered now byFunctionSnapshotContext
itself.- Specified by:
snapshotState
in interfaceCheckpointedFunction
- Parameters:
context
- the context for drawing a snapshot of the operator- Throws:
Exception
- Thrown, if state could not be created ot restored.
-
initializeState
public void initializeState(FunctionInitializationContext context) throws Exception
Description copied from interface:CheckpointedFunction
This method is called when the parallel function instance is created during distributed execution. Functions typically set up their state storing data structures in this method.- Specified by:
initializeState
in interfaceCheckpointedFunction
- Parameters:
context
- the context for initializing the operator- Throws:
Exception
- Thrown, if state could not be created ot restored.
-
-