Package org.apache.lucene.store
Class NIOFSDirectory.NIOFSIndexInput
- java.lang.Object
-
- org.apache.lucene.store.DataInput
-
- org.apache.lucene.store.IndexInput
-
- org.apache.lucene.store.BufferedIndexInput
-
- org.apache.lucene.store.NIOFSDirectory.NIOFSIndexInput
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Cloneable
,RandomAccessInput
- Enclosing class:
- NIOFSDirectory
static final class NIOFSDirectory.NIOFSIndexInput extends BufferedIndexInput
Reads bytes withFileChannel.read(ByteBuffer, long)
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBuffer
byteBuf
protected java.nio.channels.FileChannel
channel
the file channel we will read fromprivate 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 itprotected long
off
start offset: non-zero in the slice case-
Fields inherited from class org.apache.lucene.store.BufferedIndexInput
buffer, BUFFER_SIZE, MERGE_BUFFER_SIZE, MIN_BUFFER_SIZE
-
-
Constructor Summary
Constructors Constructor Description NIOFSIndexInput(java.lang.String resourceDesc, java.nio.channels.FileChannel fc, long off, long length, int bufferSize)
NIOFSIndexInput(java.lang.String resourceDesc, java.nio.channels.FileChannel fc, IOContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class org.apache.lucene.store.BufferedIndexInput
bufferSize, flushBuffer, 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 for reads of 16384 bytes.- See Also:
- Constant Field Values
-
channel
protected final java.nio.channels.FileChannel channel
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)
-
byteBuf
private java.nio.ByteBuffer byteBuf
-
-
Constructor Detail
-
NIOFSIndexInput
public NIOFSIndexInput(java.lang.String resourceDesc, java.nio.channels.FileChannel fc, IOContext context) throws java.io.IOException
- Throws:
java.io.IOException
-
NIOFSIndexInput
public NIOFSIndexInput(java.lang.String resourceDesc, java.nio.channels.FileChannel fc, long off, long length, int bufferSize)
-
-
Method Detail
-
close
public void close() throws java.io.IOException
Description copied from class:IndexInput
Closes the stream to further operations.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classIndexInput
- Throws:
java.io.IOException
-
clone
public NIOFSDirectory.NIOFSIndexInput clone()
Description copied from class:IndexInput
Returns 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
IndexInput
s, it will only callIndexInput.close()
on the original object.If you access the cloned IndexInput after closing the original object, any
readXXX
methods will throwAlreadyClosedException
.This method is NOT thread safe, so if the current
IndexInput
is being used by one thread whileclone
is called by another, disaster could strike.- Overrides:
clone
in classBufferedIndexInput
-
slice
public IndexInput slice(java.lang.String sliceDescription, long offset, long length) throws java.io.IOException
Description copied from class:IndexInput
Creates a slice of this index input, with the given description, offset, and length. The slice is sought to the beginning.- Overrides:
slice
in classBufferedIndexInput
- Throws:
java.io.IOException
-
length
public final long length()
Description copied from class:IndexInput
The number of bytes in the file.- Specified by:
length
in classIndexInput
-
newBuffer
protected void newBuffer(byte[] newBuffer)
- Overrides:
newBuffer
in classBufferedIndexInput
-
readInternal
protected void readInternal(byte[] b, int offset, int len) throws java.io.IOException
Description copied from class:BufferedIndexInput
Expert: implements buffer refill. Reads bytes from the current position in the input.- Specified by:
readInternal
in classBufferedIndexInput
- Parameters:
b
- the array to read bytes intooffset
- the offset in the array to start storing byteslen
- the number of bytes to read- Throws:
java.io.IOException
-
seekInternal
protected void seekInternal(long pos) throws java.io.IOException
Description copied from class:BufferedIndexInput
Expert: implements seek. Sets current position in this file, where the nextBufferedIndexInput.readInternal(byte[],int,int)
will occur.- Specified by:
seekInternal
in classBufferedIndexInput
- Throws:
java.io.IOException
- See Also:
BufferedIndexInput.readInternal(byte[],int,int)
-
-