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
ConstructorsConstructorDescriptionAsyncDirectIOIndexInput(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 TypeMethodDescriptionclone()voidclose()longlonglength()voidprefetch(long pos, long length) Prefetches the given range of bytes.bytereadByte()voidreadBytes(byte[] dst, int offset, int len) voidreadFloats(float[] dst, int offset, int len) intreadInt()voidreadInts(int[] dst, int offset, int len) longreadLong()voidreadLongs(long[] dst, int offset, int len) shortvoidseek(long pos) org.apache.lucene.store.IndexInputMethods inherited from class org.apache.lucene.store.IndexInput
getFullSliceDescription, isLoaded, randomAccessSlice, skipBytes, slice, toString, updateIOContextMethods inherited from class org.apache.lucene.store.DataInput
readBytes, readGroupVInt, readMapOfStrings, readSetOfStrings, readString, readVInt, readVLong, readZInt, readZLong
-
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 readblockSize- 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/OIOException- if the operating system or filesystem does not support Direct I/O or a sufficient equivalent.
-
-
Method Details
-
prefetch
Prefetches the given range of bytes. The range will be aligned to blockSize and will be chopped up into chunks of buffer size.- Overrides:
prefetchin classorg.apache.lucene.store.IndexInput- Parameters:
pos- the position to prefetch from, must be non-negative and within file lengthlength- 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
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classorg.apache.lucene.store.IndexInput- Throws:
IOException
-
getFilePointer
public long getFilePointer()- Specified by:
getFilePointerin classorg.apache.lucene.store.IndexInput
-
seek
- Specified by:
seekin classorg.apache.lucene.store.IndexInput- Throws:
IOException
-
length
public long length()- Specified by:
lengthin classorg.apache.lucene.store.IndexInput
-
readByte
- Specified by:
readBytein classorg.apache.lucene.store.DataInput- Throws:
IOException
-
readShort
- Overrides:
readShortin classorg.apache.lucene.store.DataInput- Throws:
IOException
-
readInt
- Overrides:
readIntin classorg.apache.lucene.store.DataInput- Throws:
IOException
-
readLong
- Overrides:
readLongin classorg.apache.lucene.store.DataInput- Throws:
IOException
-
readBytes
- Specified by:
readBytesin classorg.apache.lucene.store.DataInput- Throws:
IOException
-
readInts
- Overrides:
readIntsin classorg.apache.lucene.store.DataInput- Throws:
IOException
-
readFloats
- Overrides:
readFloatsin classorg.apache.lucene.store.DataInput- Throws:
IOException
-
readLongs
- Overrides:
readLongsin classorg.apache.lucene.store.DataInput- Throws:
IOException
-
clone
- Overrides:
clonein classorg.apache.lucene.store.IndexInput
-
slice
public org.apache.lucene.store.IndexInput slice(String sliceDescription, long offset, long length) throws IOException - Specified by:
slicein classorg.apache.lucene.store.IndexInput- Throws:
IOException
-