java.lang.Object
org.apache.lucene.store.DataInput
org.apache.lucene.store.IndexInput
org.apache.lucene.store.BufferedIndexInput
org.apache.lucene.misc.store.RAFDirectory.RAFIndexInput
- All Implemented Interfaces:
Closeable,AutoCloseable,Cloneable,RandomAccessInput
- Enclosing class:
RAFDirectory
Reads bytes with
RandomAccessFile.seek(long) followed by RandomAccessFile.read(byte[], int, int).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intThe maximum chunk size is 8192 bytes, becauseRandomAccessFilemallocs a native buffer outside of stack if the read buffer size is larger.protected final longend offset (start+length)protected final RandomAccessFilethe file channel we will read from(package private) booleanis this instance a clone and hence does not own the file to close itprotected final longstart offset: non-zero in the slice caseFields inherited from class org.apache.lucene.store.BufferedIndexInput
BUFFER_SIZE, MERGE_BUFFER_SIZE, MIN_BUFFER_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionRAFIndexInput(String resourceDesc, RandomAccessFile file, long off, long length, int bufferSize) RAFIndexInput(String resourceDesc, RandomAccessFile file, IOContext context) -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a clone of this stream.voidclose()Closes the stream to further operations.(package private) booleanfinal longlength()The number of bytes in the file.protected voidIndexInput methodsprotected voidseekInternal(long pos) Expert: implements seek.Creates a slice of this index input, with the given description, offset, and length.Methods inherited from class org.apache.lucene.store.BufferedIndexInput
bufferSize, getBufferSize, getFilePointer, readByte, readByte, readBytes, readBytes, readFloats, readGroupVInt, readInt, readInt, readInts, readLong, readLong, readLongs, readShort, readShort, readVInt, readVLong, seek, wrapMethods inherited from class org.apache.lucene.store.IndexInput
getFullSliceDescription, randomAccessSlice, skipBytes, toStringMethods inherited from class org.apache.lucene.store.DataInput
readGroupVInts, readMapOfStrings, readSetOfStrings, readString, readZInt, readZLong
-
Field Details
-
CHUNK_SIZE
private static final int CHUNK_SIZEThe maximum chunk size is 8192 bytes, becauseRandomAccessFilemallocs a native buffer outside of stack if the read buffer size is larger.- See Also:
-
file
the file channel we will read from -
isClone
boolean isCloneis this instance a clone and hence does not own the file to close it -
off
protected final long offstart offset: non-zero in the slice case -
end
protected final long endend offset (start+length)
-
-
Constructor Details
-
RAFIndexInput
public RAFIndexInput(String resourceDesc, RandomAccessFile file, IOContext context) throws IOException - Throws:
IOException
-
RAFIndexInput
public RAFIndexInput(String resourceDesc, RandomAccessFile file, long off, long length, int bufferSize)
-
-
Method Details
-
close
Description copied from class:IndexInputCloses the stream to further operations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classIndexInput- Throws:
IOException
-
clone
Description copied from class:IndexInputReturns a clone of this stream.Clones of a stream access the same data, and are positioned at the same point as the stream they were cloned from.
Expert: Subclasses must ensure that clones may be positioned at different points in the input from each other and from the stream they were cloned from.
Warning: Lucene never closes cloned
IndexInputs, it will only callIndexInput.close()on the original object.If you access the cloned IndexInput after closing the original object, any
readXXXmethods will throwAlreadyClosedException.This method is NOT thread safe, so if the current
IndexInputis being used by one thread whilecloneis called by another, disaster could strike.- Overrides:
clonein classBufferedIndexInput
-
slice
Description copied from class:IndexInputCreates a slice of this index input, with the given description, offset, and length. The slice is sought to the beginning.- Overrides:
slicein classBufferedIndexInput- Throws:
IOException
-
length
public final long length()Description copied from class:IndexInputThe number of bytes in the file.- Specified by:
lengthin interfaceRandomAccessInput- Specified by:
lengthin classIndexInput
-
readInternal
IndexInput methods- Specified by:
readInternalin classBufferedIndexInput- Parameters:
b- the buffer to read bytes into- Throws:
IOException
-
seekInternal
Description copied from class:BufferedIndexInputExpert: implements seek. Sets current position in this file, where the nextBufferedIndexInput.readInternal(ByteBuffer)will occur.- Specified by:
seekInternalin classBufferedIndexInput- Throws:
IOException- See Also:
-
isFDValid
- Throws:
IOException
-