static final class NIOFSDirectory.NIOFSIndexInput extends BufferedIndexInput
FileChannel.read(ByteBuffer, long)
Modifier and Type | Field and Description |
---|---|
private java.nio.ByteBuffer |
byteBuf |
protected java.nio.channels.FileChannel |
channel
the file channel we will read from
|
private static int |
CHUNK_SIZE
The maximum chunk size for reads of 16384 bytes.
|
protected long |
end
end offset (start+length)
|
(package private) boolean |
isClone
is this instance a clone and hence does not own the file to close it
|
protected long |
off
start offset: non-zero in the slice case
|
buffer, BUFFER_SIZE, MERGE_BUFFER_SIZE, MIN_BUFFER_SIZE
Constructor and Description |
---|
NIOFSIndexInput(java.lang.String resourceDesc,
java.nio.channels.FileChannel fc,
IOContext context) |
NIOFSIndexInput(java.lang.String resourceDesc,
java.nio.channels.FileChannel fc,
long off,
long length,
int bufferSize) |
Modifier and Type | Method and Description |
---|---|
NIOFSDirectory.NIOFSIndexInput |
clone()
Returns a clone of this stream.
|
void |
close()
Closes the stream to further operations.
|
long |
length()
The number of bytes in the file.
|
protected void |
newBuffer(byte[] newBuffer) |
protected void |
readInternal(byte[] b,
int offset,
int len)
Expert: implements buffer refill.
|
protected void |
seekInternal(long pos)
Expert: implements seek.
|
IndexInput |
slice(java.lang.String sliceDescription,
long offset,
long length)
Creates a slice of this index input, with the given description, offset, and length.
|
bufferSize, flushBuffer, getBufferSize, getFilePointer, readByte, readByte, readBytes, readBytes, readInt, readInt, readLong, readLong, readShort, readShort, readVInt, readVLong, seek, setBufferSize, wrap
getFullSliceDescription, randomAccessSlice, toString
readMapOfStrings, readSetOfStrings, readString, readZInt, readZLong, skipBytes
private static final int CHUNK_SIZE
protected final java.nio.channels.FileChannel channel
boolean isClone
protected final long off
protected final long end
private java.nio.ByteBuffer byteBuf
public NIOFSIndexInput(java.lang.String resourceDesc, java.nio.channels.FileChannel fc, IOContext context) throws java.io.IOException
java.io.IOException
public NIOFSIndexInput(java.lang.String resourceDesc, java.nio.channels.FileChannel fc, long off, long length, int bufferSize)
public void close() throws java.io.IOException
IndexInput
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class IndexInput
java.io.IOException
public NIOFSDirectory.NIOFSIndexInput clone()
IndexInput
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
IndexInput
s, it will only call IndexInput.close()
on the original object.
If you access the cloned IndexInput after closing the original object,
any readXXX
methods will throw AlreadyClosedException
.
This method is NOT thread safe, so if the current IndexInput
is being used by one thread while clone
is called by another,
disaster could strike.
clone
in class BufferedIndexInput
public IndexInput slice(java.lang.String sliceDescription, long offset, long length) throws java.io.IOException
IndexInput
slice
in class BufferedIndexInput
java.io.IOException
public final long length()
IndexInput
length
in class IndexInput
protected void newBuffer(byte[] newBuffer)
newBuffer
in class BufferedIndexInput
protected void readInternal(byte[] b, int offset, int len) throws java.io.IOException
BufferedIndexInput
readInternal
in class BufferedIndexInput
b
- the array to read bytes intooffset
- the offset in the array to start storing byteslen
- the number of bytes to readjava.io.IOException
protected void seekInternal(long pos) throws java.io.IOException
BufferedIndexInput
BufferedIndexInput.readInternal(byte[],int,int)
will occur.seekInternal
in class BufferedIndexInput
java.io.IOException
BufferedIndexInput.readInternal(byte[],int,int)