Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

/**
 * An interface marking that given {@link FileSystem} have an optimised path for copying paths
 * instead of using {@link FSDataOutputStream} or {@link FSDataInputStream}.
 */
@Experimental
public interface PathsCopyingFileSystem extends IFileSystem {
    /** A pair of source and destination to duplicate a file. */
    interface CopyRequest {
        /** The path of the source file to duplicate. */
        Path getSource();

        /** The path where to duplicate the source file. */
        Path getDestination();

        /** A factory method for creating a simple pair of source/destination. */
        static CopyRequest of(Path source, Path destination) {
            return new CopyRequest() {
                @Override
                public Path getSource() {
                    return source;
                }

                @Override
                public Path getDestination() {
                    return destination;
                }
                
                @Override
                public String toString() {
                    return "CopyRequest{" + "source=" + source + ", destination=" + destination + '}';
                }
            };
        }
    }

    /**
     * List of {@link CopyRequest} to copy in batch by this {@link PathsCopyingFileSystem}. In case of
     * an exception some files might have been already copied fully or partially. Caller should
     * clean this up. Copy can be interrupted by the {@link CloseableRegistry}.
     */
    void copyFiles(List<CopyRequest> requests, ICloseableRegistry closeableRegistry)
            throws IOException;

    @Override
    default boolean canCopyPaths(Path source, Path destination) throws IOException {
        return true;
    }
}

This is a slightly modified and renamed version of DuplicatingFileSystem. DuplicatingFileSystem will be removed and replaced with PathsCopyingFileSystem.  

In order for the runtime to differentiate between state handles that can be copied as files (like FileStateHandle) vs those that can not (like ByteStreamStateHandle), StreamStateHandle would have to be enriched with:

...