Class NativeIO

java.lang.Object
org.apache.druid.java.util.common.io.NativeIO

public class NativeIO extends Object
Native I/O operations in order to minimize cache impact.
  • Method Details

    • getfd

      public static int getfd(FileDescriptor descriptor)
      Get system file descriptor (int) from FileDescriptor object.
      Parameters:
      descriptor - - FileDescriptor object to get fd from
      Returns:
      file descriptor, -1 or error
    • trySkipCache

      public static void trySkipCache(int fd, long offset, long len)
      Remove pages from the file system page cache when they wont be accessed again
      Parameters:
      fd - The file descriptor of the source file.
      offset - The offset within the file.
      len - The length to be flushed.
    • chunkedCopy

      public static void chunkedCopy(InputStream src, File dest) throws IOException
      Copy from an input stream to a file minimizing cache impact on the destination.. This happens chunk by chunk so only at most chunk size will be present in the OS page cache. Posix (Linux, BSD) only. The implementation in this method is based on a post by Linus Torvalds here: http://lkml.iu.edu/hypermail/linux/kernel/1005.2/01845.html
      Parameters:
      src - Source InputStream where to copy from
      dest - Destination file to copy to
      Throws:
      IOException