Class AsyncDirectIOIndexInput

java.lang.Object
org.apache.lucene.store.DataInput
org.apache.lucene.store.IndexInput
org.elasticsearch.index.store.AsyncDirectIOIndexInput
All Implemented Interfaces:
Closeable, AutoCloseable, Cloneable

public class AsyncDirectIOIndexInput extends org.apache.lucene.store.IndexInput
An implementation of IndexInput that uses Direct I/O to bypass OS cache and provides asynchronous prefetching of data.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AsyncDirectIOIndexInput(Path path, int blockSize, int bufferSize, int maxPrefetches)
    Creates a new instance of AsyncDirectIOIndexInput for reading index input with direct IO bypassing OS buffer
  • Method Summary

    Modifier and Type
    Method
    Description
     
    void
     
    long
     
    long
     
    void
    prefetch(long pos, long length)
    Prefetches the given range of bytes.
    byte
     
    void
    readBytes(byte[] dst, int offset, int len)
     
    void
    readFloats(float[] dst, int offset, int len)
     
    int
     
    void
    readInts(int[] dst, int offset, int len)
     
    long
     
    void
    readLongs(long[] dst, int offset, int len)
     
    short
     
    void
    seek(long pos)
     
    org.apache.lucene.store.IndexInput
    slice(String sliceDescription, long offset, long length)
     

    Methods inherited from class org.apache.lucene.store.IndexInput

    getFullSliceDescription, isLoaded, randomAccessSlice, skipBytes, slice, toString, updateIOContext

    Methods inherited from class org.apache.lucene.store.DataInput

    readBytes, readGroupVInt, readMapOfStrings, readSetOfStrings, readString, readVInt, readVLong, readZInt, readZLong

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AsyncDirectIOIndexInput

      public AsyncDirectIOIndexInput(Path path, int blockSize, int bufferSize, int maxPrefetches) throws IOException
      Creates a new instance of AsyncDirectIOIndexInput for reading index input with direct IO bypassing OS buffer
      Parameters:
      path - the path to the file to read
      blockSize - the block size to use for alignment. This must match the filesystem block size, otherwise an IOException will be thrown.
      bufferSize - the size of the read buffer. This must be a multiple of blockSize.
      maxPrefetches - the maximum number of concurrent prefetches to allow. This also determines the maximum number of total prefetches that can be outstanding. The total number of prefetches is maxPrefetches * 16. A larger number of maxPrefetches allows for more aggressive prefetching, but also uses more memory (maxPrefetches * bufferSize).
      Throws:
      UnsupportedOperationException - if the JDK does not support Direct I/O
      IOException - if the operating system or filesystem does not support Direct I/O or a sufficient equivalent.
  • Method Details

    • prefetch

      public void prefetch(long pos, long length) throws IOException
      Prefetches the given range of bytes. The range will be aligned to blockSize and will be chopped up into chunks of buffer size.
      Overrides:
      prefetch in class org.apache.lucene.store.IndexInput
      Parameters:
      pos - the position to prefetch from, must be non-negative and within file length
      length - the length to prefetch, must be non-negative. This length may cause multiple prefetches to be issued, depending on the buffer size.
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class org.apache.lucene.store.IndexInput
      Throws:
      IOException
    • getFilePointer

      public long getFilePointer()
      Specified by:
      getFilePointer in class org.apache.lucene.store.IndexInput
    • seek

      public void seek(long pos) throws IOException
      Specified by:
      seek in class org.apache.lucene.store.IndexInput
      Throws:
      IOException
    • length

      public long length()
      Specified by:
      length in class org.apache.lucene.store.IndexInput
    • readByte

      public byte readByte() throws IOException
      Specified by:
      readByte in class org.apache.lucene.store.DataInput
      Throws:
      IOException
    • readShort

      public short readShort() throws IOException
      Overrides:
      readShort in class org.apache.lucene.store.DataInput
      Throws:
      IOException
    • readInt

      public int readInt() throws IOException
      Overrides:
      readInt in class org.apache.lucene.store.DataInput
      Throws:
      IOException
    • readLong

      public long readLong() throws IOException
      Overrides:
      readLong in class org.apache.lucene.store.DataInput
      Throws:
      IOException
    • readBytes

      public void readBytes(byte[] dst, int offset, int len) throws IOException
      Specified by:
      readBytes in class org.apache.lucene.store.DataInput
      Throws:
      IOException
    • readInts

      public void readInts(int[] dst, int offset, int len) throws IOException
      Overrides:
      readInts in class org.apache.lucene.store.DataInput
      Throws:
      IOException
    • readFloats

      public void readFloats(float[] dst, int offset, int len) throws IOException
      Overrides:
      readFloats in class org.apache.lucene.store.DataInput
      Throws:
      IOException
    • readLongs

      public void readLongs(long[] dst, int offset, int len) throws IOException
      Overrides:
      readLongs in class org.apache.lucene.store.DataInput
      Throws:
      IOException
    • clone

      public AsyncDirectIOIndexInput clone()
      Overrides:
      clone in class org.apache.lucene.store.IndexInput
    • slice

      public org.apache.lucene.store.IndexInput slice(String sliceDescription, long offset, long length) throws IOException
      Specified by:
      slice in class org.apache.lucene.store.IndexInput
      Throws:
      IOException