Class IndexInput
- All Implemented Interfaces:
Closeable,AutoCloseable,Cloneable
- Direct Known Subclasses:
BufferedIndexInput,ChecksumIndexInput,RAMInputStream
Directory. A
random-access input stream. Used for all Lucene index input operations.
IndexInput may only be used from one thread, because it is not
thread safe (it keeps internal state like file position). To allow
multithreaded use, every IndexInput instance must be cloned before
used in another thread. Subclasses must therefore implement clone(),
returning a new IndexInput which operates on the same underlying
resource, but positioned independently. Lucene never closes cloned
IndexInputs, it will only do this on the original one.
The original instance must take care that cloned instances throw
AlreadyClosedException when the original one is closed.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedIndexInput(String resourceDescription) resourceDescription should be a non-null, opaque string describing this resource; it's returned fromtoString(). -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a clone of this stream.abstract voidclose()Closes the stream to further operations.abstract longReturns the current position in this file, where the next read will occur.abstract longlength()The number of bytes in the file.abstract voidseek(long pos) Sets current position in this file, where the next read will occur.toString()Methods inherited from class org.apache.lucene.store.DataInput
readByte, readBytes, readBytes, readInt, readLong, readShort, readString, readStringSet, readStringStringMap, readVInt, readVLong
-
Constructor Details
-
IndexInput
resourceDescription should be a non-null, opaque string describing this resource; it's returned fromtoString().
-
-
Method Details
-
close
Closes the stream to further operations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getFilePointer
public abstract long getFilePointer()Returns the current position in this file, where the next read will occur.- See Also:
-
seek
Sets current position in this file, where the next read will occur.- Throws:
IOException- See Also:
-
length
public abstract long length()The number of bytes in the file. -
toString
-
clone
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
IndexInputs, it will only do this on the original one. The original instance must take care that cloned instances throwAlreadyClosedExceptionwhen the original one is closed.
-