Class CacheFileSystem

java.lang.Object
io.trino.filesystem.cache.CacheFileSystem
All Implemented Interfaces:
TrinoFileSystem

public final class CacheFileSystem extends Object implements TrinoFileSystem
  • Constructor Details

  • Method Details

    • newInputFile

      public TrinoInputFile newInputFile(Location location)
      Description copied from interface: TrinoFileSystem
      Creates 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:
      newInputFile in interface TrinoFileSystem
    • newInputFile

      public TrinoInputFile newInputFile(Location location, long length)
      Description copied from interface: TrinoFileSystem
      Creates a TrinoInputFile with a predeclared length which can be used to read the file data. The length will be returned from TrinoInputFile.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:
      newInputFile in interface TrinoFileSystem
    • newOutputFile

      public TrinoOutputFile newOutputFile(Location location)
      Description copied from interface: TrinoFileSystem
      Creates 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:
      newOutputFile in interface TrinoFileSystem
    • deleteFile

      public void deleteFile(Location location) throws IOException
      Description copied from interface: TrinoFileSystem
      Deletes the specified file. The file location path cannot be empty, and must not end with a slash or whitespace. If the file is a directory, an exception is raised. If the file does not exist, this method is a noop.
      Specified by:
      deleteFile in interface TrinoFileSystem
      Throws:
      IOException
    • deleteDirectory

      public void deleteDirectory(Location location) throws IOException
      Description copied from interface: TrinoFileSystem
      Deletes 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:
      deleteDirectory in interface TrinoFileSystem
      Parameters:
      location - the directory to delete
      Throws:
      IOException
    • renameFile

      public void renameFile(Location source, Location target) throws IOException
      Description copied from interface: TrinoFileSystem
      Rename 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.

      For file systems which do not support rename (e.g. S3), this operation fails.

      Specified by:
      renameFile in interface TrinoFileSystem
      Throws:
      IOException
    • listFiles

      public FileIterator listFiles(Location location) throws IOException
      Description copied from interface: TrinoFileSystem
      Lists 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:
      listFiles in interface TrinoFileSystem
      Parameters:
      location - the directory to list
      Throws:
      IOException
    • directoryExists

      public Optional<Boolean> directoryExists(Location location) throws IOException
      Description copied from interface: TrinoFileSystem
      Checks 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 by TrinoFileSystem.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:
      directoryExists in interface TrinoFileSystem
      Parameters:
      location - the location to check for a directory
      Throws:
      IOException
    • createDirectory

      public void createDirectory(Location location) throws IOException
      Description copied from interface: TrinoFileSystem
      Creates 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:
      createDirectory in interface TrinoFileSystem
      Throws:
      IOException
    • renameDirectory

      public void renameDirectory(Location source, Location target) throws IOException
      Description copied from interface: TrinoFileSystem
      Renames source to target. An exception is raised if the target already exists, or on non-hierarchical file systems.
      Specified by:
      renameDirectory in interface TrinoFileSystem
      Throws:
      IOException
    • listDirectories

      public Set<Location> listDirectories(Location location) throws IOException
      Description copied from interface: TrinoFileSystem
      Lists all directories that are direct descendants of the specified directory. If the path is empty, all directories at the root of the file system are returned. Otherwise, the path must end with a slash. If the location does not exist, an empty set 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 directories containing blobs that start with the location are listed.

      Specified by:
      listDirectories in interface TrinoFileSystem
      Throws:
      IOException
    • createTemporaryDirectory

      public Optional<Location> createTemporaryDirectory(Location targetPath, String temporaryPrefix, String relativePrefix) throws IOException
      Description copied from interface: TrinoFileSystem
      Creates a temporary directory for the target path. The directory will be created using the (possibly absolute) prefix such that the directory can be renamed to the target path. The relative prefix will be used if the target path does not support the temporary prefix (which is typically absolute).

      The temporary directory is not created for non-hierarchical file systems or for target paths that do not support renaming, and an empty optional is returned.

      Specified by:
      createTemporaryDirectory in interface TrinoFileSystem
      Throws:
      IOException
    • deleteFiles

      public void deleteFiles(Collection<Location> locations) throws IOException
      Description copied from interface: TrinoFileSystem
      Delete specified files. This operation is not required to be atomic, so if an error occurs, all, some, or, none of the files may be deleted. This operation may be faster than simply looping over the locations as some file systems support batch delete operations natively. If a file does not exist, it is ignored.
      Specified by:
      deleteFiles in interface TrinoFileSystem
      Throws:
      IOException