Class FileStateHandle
java.lang.Object
org.apache.flink.runtime.state.filesystem.FileStateHandle
- All Implemented Interfaces:
Serializable,StateObject,StreamStateHandle
- Direct Known Subclasses:
RelativeFileStateHandle
StreamStateHandle for state that was written to a file stream. The written data is
identified by the file path. The state can be read again by calling openInputStream().- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.flink.runtime.state.StateObject
StateObject.StateObjectLocation, StateObject.StateObjectSizeStatsCollector -
Constructor Summary
ConstructorsConstructorDescriptionFileStateHandle(org.apache.flink.core.fs.Path filePath, long stateSize) Creates a new file state for the given file path. -
Method Summary
Modifier and TypeMethodDescriptionOptional<byte[]>voidCollects statistics about state size and location from the state object.voidDiscard the state by deleting the file that stores the state.booleanorg.apache.flink.core.fs.PathGets the path where this handle's state is stored.longReturns the file size in bytes.inthashCode()Optional<org.apache.flink.core.fs.Path>org.apache.flink.core.fs.FSDataInputStreamReturns anFSDataInputStreamthat can be used to read back the data that was previously written to the stream.toString()
-
Constructor Details
-
FileStateHandle
public FileStateHandle(org.apache.flink.core.fs.Path filePath, long stateSize) Creates a new file state for the given file path.- Parameters:
filePath- The path to the file that stores the state.
-
-
Method Details
-
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
Description 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
- Specified by:
asBytesIfInMemoryin interfaceStreamStateHandle- Returns:
- Content of this handle as bytes array if it is already in memory.
-
getStreamStateHandleID
- Specified by:
getStreamStateHandleIDin interfaceStreamStateHandle- Returns:
- a unique identifier of this handle.
-
discardState
Discard 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
Description copied from interface:StateObjectCollects statistics about state size and location from the state object.- Specified by:
collectSizeStatsin interfaceStateObject- Parameters:
collector- the statistics collector.
-
equals
-
hashCode
public int hashCode() -
toString
-