Class FileStateHandle
- java.lang.Object
-
- org.apache.flink.runtime.state.filesystem.FileStateHandle
-
- All Implemented Interfaces:
Serializable,StateObject,StreamStateHandle
- Direct Known Subclasses:
RelativeFileStateHandle
public class FileStateHandle extends Object implements StreamStateHandle
StreamStateHandlefor state that was written to a file stream. The written data is identified by the file path. The state can be read again by callingopenInputStream().- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.state.StateObject
StateObject.StateObjectLocation, StateObject.StateObjectSizeStatsCollector
-
-
Constructor Summary
Constructors Constructor Description FileStateHandle(org.apache.flink.core.fs.Path filePath, long stateSize)Creates a new file state for the given file path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<byte[]>asBytesIfInMemory()voidcollectSizeStats(StateObject.StateObjectSizeStatsCollector collector)Collects statistics about state size and location from the state object.voiddiscardState()Discard the state by deleting the file that stores the state.booleanequals(Object o)org.apache.flink.core.fs.PathgetFilePath()Gets the path where this handle's state is stored.longgetStateSize()Returns the file size in bytes.PhysicalStateHandleIDgetStreamStateHandleID()inthashCode()Optional<org.apache.flink.core.fs.Path>maybeGetPath()org.apache.flink.core.fs.FSDataInputStreamopenInputStream()Returns anFSDataInputStreamthat can be used to read back the data that was previously written to the stream.StringtoString()
-
-
-
Method Detail
-
maybeGetPath
public Optional<org.apache.flink.core.fs.Path> maybeGetPath()
- Specified by:
maybeGetPathin interfaceStreamStateHandle- Returns:
- Path to an underlying file represented by this
StreamStateHandleorOptional.empty()if there is no such file.
-
getFilePath
public org.apache.flink.core.fs.Path getFilePath()
Gets the path where this handle's state is stored.- Returns:
- The path where this handle's state is stored.
-
openInputStream
public org.apache.flink.core.fs.FSDataInputStream openInputStream() throws IOExceptionDescription copied from interface:StreamStateHandleReturns anFSDataInputStreamthat can be used to read back the data that was previously written to the stream.- Specified by:
openInputStreamin interfaceStreamStateHandle- Throws:
IOException
-
asBytesIfInMemory
public Optional<byte[]> asBytesIfInMemory()
- Specified by:
asBytesIfInMemoryin interfaceStreamStateHandle- Returns:
- Content of this handle as bytes array if it is already in memory.
-
getStreamStateHandleID
public PhysicalStateHandleID getStreamStateHandleID()
- Specified by:
getStreamStateHandleIDin interfaceStreamStateHandle- Returns:
- a unique identifier of this handle.
-
discardState
public void discardState() throws ExceptionDiscard the state by deleting the file that stores the state. If the parent directory of the state is empty after deleting the state file, it is also deleted.- Specified by:
discardStatein interfaceStateObject- Throws:
Exception- Thrown, if the file deletion (not the directory deletion) fails.
-
getStateSize
public long getStateSize()
Returns the file size in bytes.- Specified by:
getStateSizein interfaceStateObject- Returns:
- The file size in bytes.
-
collectSizeStats
public void collectSizeStats(StateObject.StateObjectSizeStatsCollector collector)
Description copied from interface:StateObjectCollects statistics about state size and location from the state object.- Specified by:
collectSizeStatsin interfaceStateObject- Parameters:
collector- the statistics collector.
-
-