K
- The type of the key.OUT
- The type of the output of the KeyedStateReaderFunction
.@Internal public class KeyedStateInputFormat<K,OUT> extends RichInputFormat<OUT,KeyGroupRangeInputSplit> implements KeyContext
Constructor and Description |
---|
KeyedStateInputFormat(OperatorState operatorState,
StateBackend stateBackend,
TypeInformation<K> keyType,
KeyedStateReaderFunction<K,OUT> userFunction)
Creates an input format for reading partitioned state from an operator in a savepoint.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Method that marks the end of the life-cycle of an input split.
|
void |
configure(Configuration parameters)
Configures this input format.
|
KeyGroupRangeInputSplit[] |
createInputSplits(int minNumSplits)
Creates the different splits of the input that can be processed in parallel.
|
Object |
getCurrentKey() |
InputSplitAssigner |
getInputSplitAssigner(KeyGroupRangeInputSplit[] inputSplits)
Gets the type of the input splits that are processed by this input format.
|
BaseStatistics |
getStatistics(BaseStatistics cachedStatistics)
Gets the basic statistics from the input described by this format.
|
OUT |
nextRecord(OUT reuse)
Reads the next record from the input.
|
void |
open(KeyGroupRangeInputSplit split)
Opens a parallel instance of the input format to work on a split.
|
void |
openInputFormat()
Opens this InputFormat instance.
|
boolean |
reachedEnd()
Method used to check if the end of the input is reached.
|
void |
setCurrentKey(Object key) |
closeInputFormat, getRuntimeContext, setRuntimeContext
public KeyedStateInputFormat(OperatorState operatorState, StateBackend stateBackend, TypeInformation<K> keyType, KeyedStateReaderFunction<K,OUT> userFunction)
operatorState
- The state to be queried.stateBackend
- The state backed used to snapshot the operator.keyType
- The type information describing the key type.userFunction
- The KeyedStateReaderFunction
called for each key in the operator.public void configure(Configuration parameters)
InputFormat
This method is always called first on a newly instantiated input format.
configure
in interface InputFormat<OUT,KeyGroupRangeInputSplit>
parameters
- The configuration with all parameters (note: not the Flink config but the TaskConfig).public InputSplitAssigner getInputSplitAssigner(KeyGroupRangeInputSplit[] inputSplits)
InputFormat
getInputSplitAssigner
in interface InputFormat<OUT,KeyGroupRangeInputSplit>
getInputSplitAssigner
in interface InputSplitSource<KeyGroupRangeInputSplit>
public BaseStatistics getStatistics(BaseStatistics cachedStatistics)
InputFormat
When this method is called, the input format it guaranteed to be configured.
getStatistics
in interface InputFormat<OUT,KeyGroupRangeInputSplit>
cachedStatistics
- The statistics that were cached. May be null.public KeyGroupRangeInputSplit[] createInputSplits(int minNumSplits) throws IOException
InputFormat
When this method is called, the input format it guaranteed to be configured.
createInputSplits
in interface InputFormat<OUT,KeyGroupRangeInputSplit>
createInputSplits
in interface InputSplitSource<KeyGroupRangeInputSplit>
minNumSplits
- The minimum desired number of splits. If fewer are created, some parallel
instances may remain idle.IOException
- Thrown, when the creation of the splits was erroneous.public void openInputFormat()
RichInputFormat
openInputFormat
in class RichInputFormat<OUT,KeyGroupRangeInputSplit>
InputFormat
public void open(KeyGroupRangeInputSplit split) throws IOException
InputFormat
When this method is called, the input format it guaranteed to be configured.
open
in interface InputFormat<OUT,KeyGroupRangeInputSplit>
split
- The split to be opened.IOException
- Thrown, if the spit could not be opened due to an I/O problem.public void close() throws IOException
InputFormat
When this method is called, the input format it guaranteed to be opened.
close
in interface InputFormat<OUT,KeyGroupRangeInputSplit>
IOException
- Thrown, if the input could not be closed properly.public boolean reachedEnd()
InputFormat
When this method is called, the input format it guaranteed to be opened.
reachedEnd
in interface InputFormat<OUT,KeyGroupRangeInputSplit>
public OUT nextRecord(OUT reuse) throws IOException
InputFormat
When this method is called, the input format it guaranteed to be opened.
nextRecord
in interface InputFormat<OUT,KeyGroupRangeInputSplit>
reuse
- Object that may be reused.IOException
- Thrown, if an I/O error occurred.public void setCurrentKey(Object key)
setCurrentKey
in interface KeyContext
public Object getCurrentKey()
getCurrentKey
in interface KeyContext
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.