Class MemoryFileSystem
- All Implemented Interfaces:
TrinoFileSystem
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateDirectory(Location location) Creates the specified directory and any parent directories that do not exist.voiddeleteDirectory(Location location) Deletes all files and directories within the specified directory recursively, and deletes the directory itself.voiddeleteFile(Location location) Deletes the specified file.directoryExists(Location location) Checks if a directory exists at the specified location.Lists all files within the specified directory recursively.newInputFile(Location location) Creates a TrinoInputFile which can be used to read the file data.newInputFile(Location location, long length) Creates a TrinoInputFile with a predeclared length which can be used to read the file data.newOutputFile(Location location) Creates a TrinoOutputFile which can be used to create or overwrite the file.voidrenameDirectory(Location source, Location target) Renames source to target.voidrenameFile(Location source, Location target) Rename source to target without overwriting target.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.trino.filesystem.TrinoFileSystem
deleteFiles
-
Constructor Details
-
MemoryFileSystem
public MemoryFileSystem()
-
-
Method Details
-
newInputFile
Description copied from interface:TrinoFileSystemCreates a TrinoInputFile which can be used to read the file data. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newInputFilein interfaceTrinoFileSystem
-
newInputFile
Description copied from interface:TrinoFileSystemCreates a TrinoInputFile with a predeclared length which can be used to read the file data. The length will be returned fromTrinoInputFile.length()and the actual file length will never be checked. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newInputFilein interfaceTrinoFileSystem
-
newOutputFile
Description copied from interface:TrinoFileSystemCreates a TrinoOutputFile which can be used to create or overwrite the file. The file location path cannot be empty, and must not end with a slash or whitespace.- Specified by:
newOutputFilein interfaceTrinoFileSystem
-
deleteFile
Description copied from interface:TrinoFileSystemDeletes the specified file. The file location path cannot be empty, and must not end with a slash or whitespace. If the file is a director, an exception is raised.- Specified by:
deleteFilein interfaceTrinoFileSystem- Throws:
IOException- if the file does not exist (optional) or was not deleted
-
deleteDirectory
Description copied from interface:TrinoFileSystemDeletes all files and directories within the specified directory recursively, and deletes the directory itself. If the location does not exist, this method is a noop. If the location does not have a path, all files and directories in the file system are deleted.For hierarchical file systems (e.g. HDFS), if the path is not a directory, an exception is raised.
For blob file systems (e.g., S3), if the location does not end with a slash, one is appended, and all blobs that start with that prefix are deleted.
If this operation fails, some, none, or all of the directory contents may have been deleted.
- Specified by:
deleteDirectoryin interfaceTrinoFileSystem- Parameters:
location- the directory to delete- Throws:
IOException
-
renameFile
Description copied from interface:TrinoFileSystemRename source to target without overwriting target. This method is not required to be atomic, but it is required that if an error occurs, the source, target, or both must exist with the data from the source. This operation may or may not preserve the last modified time.- Specified by:
renameFilein interfaceTrinoFileSystem- Throws:
IOException
-
listFiles
Description copied from interface:TrinoFileSystemLists all files within the specified directory recursively. The location can be empty, listing all files in the file system, otherwise the location must end with a slash. If the location does not exist, an empty iterator is returned.For hierarchical file systems, if the path is not a directory, an exception is raised. For hierarchical file systems, if the path does not reference an existing directory, an empty iterator is returned. For blob file systems, all blobs that start with the location are listed. In the rare case that a blob exists with the exact name of the prefix, it is not included in the results.
The returned FileEntry locations will start with the specified location exactly.
- Specified by:
listFilesin interfaceTrinoFileSystem- Parameters:
location- the directory to list- Throws:
IOException
-
directoryExists
Description copied from interface:TrinoFileSystemChecks if a directory exists at the specified location. For all file system types, this returns true if the location is empty (the root of the file system) or if any files exist within the directory, as determined byTrinoFileSystem.listFiles(Location). Otherwise:- For hierarchical file systems, this returns true if the location is an empty directory, else it returns false.
- For non-hierarchical file systems, an Optional.empty() is returned, indicating that the file system has no concept of an empty directory.
- Specified by:
directoryExistsin interfaceTrinoFileSystem- Parameters:
location- the location to check for a directory- Throws:
IOException
-
createDirectory
Description copied from interface:TrinoFileSystemCreates the specified directory and any parent directories that do not exist. For hierarchical file systems, if the location already exists but is not a directory, or if the directory cannot be created, an exception is raised. This method does nothing for non-hierarchical file systems or if the directory already exists.- Specified by:
createDirectoryin interfaceTrinoFileSystem- Throws:
IOException
-
renameDirectory
Description copied from interface:TrinoFileSystemRenames source to target. An exception is raised if the target already exists, or on non-hierarchical file systems.- Specified by:
renameDirectoryin interfaceTrinoFileSystem- Throws:
IOException
-