Class HadoopFileIO
Object
io.delta.kernel.defaults.engine.hadoopio.HadoopFileIO
- All Implemented Interfaces:
FileIO
Implementation of
FileIO based on Hadoop APIs.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyFileAtomically(String srcPath, String destPath, boolean overwrite) Atomically copy a file from source path to destination path.booleanDelete the file at given path.Get the configuration value for the given key.io.delta.kernel.utils.FileStatusgetFileStatus(String path) Get the metadata of the file at the given path.io.delta.kernel.utils.CloseableIterator<io.delta.kernel.utils.FileStatus> List the paths in the same directory that are lexicographically greater or equal to (UTF-8 sorting) the given `path`.booleanCreate a directory at the given path including parent directories.newInputFile(String path, long fileSize) Get anInputFilefor file at given path which can be used to read the file from any arbitrary position in the file.newOutputFile(String path) Create aOutputFileto write new file at the given path.resolvePath(String path) Resolve the given path to a fully qualified path.
-
Constructor Details
-
HadoopFileIO
public HadoopFileIO(org.apache.hadoop.conf.Configuration hadoopConf)
-
-
Method Details
-
listFrom
public io.delta.kernel.utils.CloseableIterator<io.delta.kernel.utils.FileStatus> listFrom(String filePath) throws IOException Description copied from interface:FileIOList the paths in the same directory that are lexicographically greater or equal to (UTF-8 sorting) the given `path`. The result should also be sorted by the file name.- Specified by:
listFromin interfaceFileIO- Parameters:
filePath- Fully qualified path to a file- Returns:
- Closeable iterator of files. It is the responsibility of the caller to close the iterator.
- Throws:
IOException- for any other IO error.
-
getFileStatus
Description copied from interface:FileIOGet the metadata of the file at the given path.- Specified by:
getFileStatusin interfaceFileIO- Parameters:
path- Fully qualified path to the file.- Returns:
- Metadata of the file.
- Throws:
IOException- for any IO error.
-
resolvePath
Description copied from interface:FileIOResolve the given path to a fully qualified path.- Specified by:
resolvePathin interfaceFileIO- Parameters:
path- Input path- Returns:
- Fully qualified path.
- Throws:
IOException- for any other IO error.
-
mkdirs
Description copied from interface:FileIOCreate a directory at the given path including parent directories. This mimics the behavior of `mkdir -p` in Unix.- Specified by:
mkdirsin interfaceFileIO- Parameters:
path- Full qualified path to create a directory at.- Returns:
- true if the directory was created successfully, false otherwise.
- Throws:
IOException- for any IO error.
-
newInputFile
Description copied from interface:FileIOGet anInputFilefor file at given path which can be used to read the file from any arbitrary position in the file.- Specified by:
newInputFilein interfaceFileIO- Parameters:
path- Fully qualified path to the file.fileSize- Size of the file in bytes.- Returns:
InputFileinstance.
-
newOutputFile
Description copied from interface:FileIOCreate aOutputFileto write new file at the given path.- Specified by:
newOutputFilein interfaceFileIO- Parameters:
path- Fully qualified path to the file.- Returns:
OutputFileinstance which can be used to write to the file.
-
delete
Description copied from interface:FileIODelete the file at given path.- Specified by:
deletein interfaceFileIO- Parameters:
path- the path to delete. If path is a directory throws an exception.- Returns:
- true if delete is successful else false.
- Throws:
IOException- for any IO error.
-
getConf
Description copied from interface:FileIOGet the configuration value for the given key.TODO: should be in a separate interface? may be called ConfigurationProvider?
- Specified by:
getConfin interfaceFileIO- Parameters:
confKey- configuration key name- Returns:
- If no such value is present, an
Optional.empty()is returned.
-
copyFileAtomically
public void copyFileAtomically(String srcPath, String destPath, boolean overwrite) throws IOException Description copied from interface:FileIOAtomically copy a file from source path to destination path. The copy operation should be atomic to ensure that the destination file is either fully copied or not present at all.- Specified by:
copyFileAtomicallyin interfaceFileIO- Parameters:
srcPath- Fully qualified path to the source file to copydestPath- Fully qualified path to the destination where the file will be copiedoverwrite- If true, overwrite the destination file if it already exists. If false, throw an exception if the destination exists.- Throws:
IOException- for any other IO error
-