Package org.apache.lucene.store
Class RAFDirectory.RAFIndexInput
- java.lang.Object
-
- org.apache.lucene.store.DataInput
-
- org.apache.lucene.store.IndexInput
-
- org.apache.lucene.store.BufferedIndexInput
-
- org.apache.lucene.store.RAFDirectory.RAFIndexInput
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Cloneable,RandomAccessInput
- Enclosing class:
- RAFDirectory
static final class RAFDirectory.RAFIndexInput extends BufferedIndexInput
Reads bytes withRandomAccessFile.seek(long)followed byRandomAccessFile.read(byte[], int, int).
-
-
Field Summary
Fields Modifier and Type Field Description private static intCHUNK_SIZEThe maximum chunk size is 8192 bytes, becauseRandomAccessFilemallocs a native buffer outside of stack if the read buffer size is larger.protected longendend offset (start+length)protected java.io.RandomAccessFilefilethe file channel we will read from(package private) booleanisCloneis this instance a clone and hence does not own the file to close itprotected longoffstart offset: non-zero in the slice case-
Fields inherited from class org.apache.lucene.store.BufferedIndexInput
BUFFER_SIZE, MERGE_BUFFER_SIZE, MIN_BUFFER_SIZE
-
-
Constructor Summary
Constructors Constructor Description RAFIndexInput(java.lang.String resourceDesc, java.io.RandomAccessFile file, long off, long length, int bufferSize)RAFIndexInput(java.lang.String resourceDesc, java.io.RandomAccessFile file, IOContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RAFDirectory.RAFIndexInputclone()Returns a clone of this stream.voidclose()Closes the stream to further operations.(package private) booleanisFDValid()longlength()The number of bytes in the file.protected voidreadInternal(java.nio.ByteBuffer b)IndexInput methodsprotected voidseekInternal(long pos)Expert: implements seek.IndexInputslice(java.lang.String sliceDescription, long offset, long length)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, readInt, readInt, readLong, readLong, readShort, readShort, readVInt, readVLong, seek, setBufferSize, wrap
-
Methods inherited from class org.apache.lucene.store.IndexInput
getFullSliceDescription, randomAccessSlice, toString
-
Methods inherited from class org.apache.lucene.store.DataInput
readLELongs, readMapOfStrings, readSetOfStrings, readString, readZInt, readZLong, skipBytes
-
-
-
-
Field Detail
-
CHUNK_SIZE
private static final int CHUNK_SIZE
The maximum chunk size is 8192 bytes, becauseRandomAccessFilemallocs a native buffer outside of stack if the read buffer size is larger.- See Also:
- Constant Field Values
-
file
protected final java.io.RandomAccessFile file
the file channel we will read from
-
isClone
boolean isClone
is this instance a clone and hence does not own the file to close it
-
off
protected final long off
start offset: non-zero in the slice case
-
end
protected final long end
end offset (start+length)
-
-
Constructor Detail
-
RAFIndexInput
public RAFIndexInput(java.lang.String resourceDesc, java.io.RandomAccessFile file, IOContext context) throws java.io.IOException- Throws:
java.io.IOException
-
RAFIndexInput
public RAFIndexInput(java.lang.String resourceDesc, java.io.RandomAccessFile file, long off, long length, int bufferSize)
-
-
Method Detail
-
close
public void close() throws java.io.IOExceptionDescription copied from class:IndexInputCloses the stream to further operations.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classIndexInput- Throws:
java.io.IOException
-
clone
public RAFDirectory.RAFIndexInput 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
public IndexInput slice(java.lang.String sliceDescription, long offset, long length) throws java.io.IOException
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:
java.io.IOException
-
length
public final long length()
Description copied from class:IndexInputThe number of bytes in the file.- Specified by:
lengthin classIndexInput
-
readInternal
protected void readInternal(java.nio.ByteBuffer b) throws java.io.IOExceptionIndexInput methods- Specified by:
readInternalin classBufferedIndexInput- Parameters:
b- the buffer to read bytes into- Throws:
java.io.IOException
-
seekInternal
protected void seekInternal(long pos) throws java.io.IOExceptionDescription copied from class:BufferedIndexInputExpert: implements seek. Sets current position in this file, where the nextBufferedIndexInput.readInternal(ByteBuffer)will occur.- Specified by:
seekInternalin classBufferedIndexInput- Throws:
java.io.IOException- See Also:
BufferedIndexInput.readInternal(ByteBuffer)
-
isFDValid
boolean isFDValid() throws java.io.IOException- Throws:
java.io.IOException
-
-