@Public @ThreadSafe public interface FileIO extends Serializable
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
Modifier and Type | Method and Description |
---|---|
default void |
checkOrMkdirs(Path path) |
void |
configure(CatalogContext context)
Configure by
CatalogContext . |
default void |
copyFile(Path sourcePath,
Path targetPath,
boolean overwrite)
Copy content of one file into another.
|
default void |
copyFiles(Path sourceDirectory,
Path targetDirectory,
boolean overwrite)
Copy all files in sourceDirectory to directory targetDirectory.
|
boolean |
delete(Path path,
boolean recursive)
Delete a file.
|
default void |
deleteDirectoryQuietly(Path directory) |
default void |
deleteFilesQuietly(List<Path> files) |
default void |
deleteQuietly(Path file) |
static Map<String,FileIOLoader> |
discoverLoaders()
Discovers all
FileIOLoader by service loader. |
boolean |
exists(Path path)
Check if exists.
|
static FileIO |
get(Path path,
CatalogContext config)
Returns a reference to the
FileIO instance for accessing the file system identified
by the given path. |
default long |
getFileSize(Path path) |
FileStatus |
getFileStatus(Path path)
Return a file status object that represents the path.
|
default boolean |
isDir(Path path) |
boolean |
isObjectStore() |
default FileStatus[] |
listDirectories(Path path)
List the statuses of the directories in the given path if the path is a directory.
|
FileStatus[] |
listStatus(Path path)
List the statuses of the files/directories in the given path if the path is a directory.
|
boolean |
mkdirs(Path path)
Make the given file and all non-existent parents into directories.
|
SeekableInputStream |
newInputStream(Path path)
Opens an SeekableInputStream at the indicated Path.
|
PositionOutputStream |
newOutputStream(Path path,
boolean overwrite)
Opens an PositionOutputStream at the indicated Path.
|
default void |
overwriteFileUtf8(Path path,
String content)
Overwrite file by content atomically, different
FileIO s have different atomic
implementations. |
default String |
readFileUtf8(Path path)
Read file to UTF_8 decoding.
|
default Optional<String> |
readOverwrittenFileUtf8(Path path)
Read file from
overwriteFileUtf8(org.apache.paimon.fs.Path, java.lang.String) file. |
boolean |
rename(Path src,
Path dst)
Renames the file/directory src to dst.
|
default boolean |
tryToWriteAtomic(Path path,
String content)
Write content to one file atomically, initially writes to temp hidden file and only renames
to the target file once temp file is closed.
|
default void |
writeFile(Path path,
String content,
boolean overwrite) |
boolean isObjectStore()
void configure(CatalogContext context)
CatalogContext
.SeekableInputStream newInputStream(Path path) throws IOException
path
- the file to openIOException
PositionOutputStream newOutputStream(Path path, boolean overwrite) throws IOException
path
- the file name to openoverwrite
- if a file with this name already exists, then if true, the file will be
overwritten, and if false an error will be thrown.IOException
- Thrown, if the stream could not be opened because of an I/O, or because a
file already exists at that path and the write mode indicates to not overwrite the file.FileStatus getFileStatus(Path path) throws IOException
path
- The path we want information fromFileNotFoundException
- when the path does not exist; IOException see specific
implementationIOException
FileStatus[] listStatus(Path path) throws IOException
path
- given pathIOException
default FileStatus[] listDirectories(Path path) throws IOException
FileIO
implementation may have optimization for list directories.
path
- given pathIOException
boolean exists(Path path) throws IOException
path
- source fileIOException
boolean delete(Path path, boolean recursive) throws IOException
path
- the path to deleterecursive
- if path is a directory and set to true
, the directory is
deleted else throws an exception. In case of a file the recursive can be set to either
true
or false
true
if delete is successful, false
otherwiseIOException
boolean mkdirs(Path path) throws IOException
path
- the directory/directories to be createdtrue
if at least one new directory has been created, false
otherwiseIOException
- thrown if an I/O error occurs while creating the directoryboolean rename(Path src, Path dst) throws IOException
src
- the file/directory to renamedst
- the new name of the file/directorytrue
if the renaming was successful, false
otherwiseIOException
default void deleteQuietly(Path file)
default void deleteDirectoryQuietly(Path directory)
default long getFileSize(Path path) throws IOException
IOException
default boolean isDir(Path path) throws IOException
IOException
default void checkOrMkdirs(Path path) throws IOException
IOException
default String readFileUtf8(Path path) throws IOException
IOException
default boolean tryToWriteAtomic(Path path, String content) throws IOException
IOException
default void writeFile(Path path, String content, boolean overwrite) throws IOException
IOException
default void overwriteFileUtf8(Path path, String content) throws IOException
FileIO
s have different atomic
implementations.IOException
default void copyFile(Path sourcePath, Path targetPath, boolean overwrite) throws IOException
IOException
- Thrown, if the stream could not be opened because of an I/O, or because
target file already exists at that path and the write mode indicates to not overwrite the
file.default void copyFiles(Path sourceDirectory, Path targetDirectory, boolean overwrite) throws IOException
IOException
default Optional<String> readOverwrittenFileUtf8(Path path) throws IOException
overwriteFileUtf8(org.apache.paimon.fs.Path, java.lang.String)
file.IOException
static FileIO get(Path path, CatalogContext config) throws IOException
FileIO
instance for accessing the file system identified
by the given path.IOException
static Map<String,FileIOLoader> discoverLoaders()
FileIOLoader
by service loader.Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.