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:
Closeable
,AutoCloseable
,Cloneable
,RandomAccessInput
- Enclosing class:
- NIOFSDirectory
Reads bytes with
FileChannel.read(ByteBuffer, long)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FileChannel
the file channel we will read fromprivate static final int
The maximum chunk size for reads of 16384 bytes.protected final long
end offset (start+length)(package private) boolean
is this instance a clone and hence does not own the file to close itprotected final long
start 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
ConstructorsConstructorDescriptionNIOFSIndexInput
(String resourceDesc, FileChannel fc, long off, long length, int bufferSize) NIOFSIndexInput
(String resourceDesc, FileChannel fc, IOContext context) -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of this stream.void
close()
Closes the stream to further operations.final long
length()
The number of bytes in the file.protected void
Expert: implements buffer refill.protected void
seekInternal
(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, readInt, readInt, readLong, readLong, readShort, readShort, readVInt, readVLong, seek, wrap
Methods inherited from class org.apache.lucene.store.IndexInput
getFullSliceDescription, randomAccessSlice, skipBytes, toString
Methods inherited from class org.apache.lucene.store.DataInput
readFloats, readInts, readLongs, readMapOfStrings, readSetOfStrings, readString, readZInt, readZLong
-
Field Details
-
CHUNK_SIZE
private static final int CHUNK_SIZEThe maximum chunk size for reads of 16384 bytes.- See Also:
-
channel
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
-
NIOFSIndexInput
- Throws:
IOException
-
NIOFSIndexInput
-
-
Method Details
-
close
Description copied from class:IndexInput
Closes the stream to further operations.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classIndexInput
- Throws:
IOException
-
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
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:
IOException
-
length
public final long length()Description copied from class:IndexInput
The number of bytes in the file.- Specified by:
length
in classIndexInput
-
readInternal
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 buffer to read bytes into- Throws:
IOException
-
seekInternal
Description copied from class:BufferedIndexInput
Expert: implements seek. Sets current position in this file, where the nextBufferedIndexInput.readInternal(ByteBuffer)
will occur.- Specified by:
seekInternal
in classBufferedIndexInput
- Throws:
IOException
- See Also:
-