Class IndexInput
- java.lang.Object
-
- org.apache.lucene.store.DataInput
-
- org.apache.lucene.store.IndexInput
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Cloneable
- Direct Known Subclasses:
BufferedIndexInput,ChecksumIndexInput,RAMInputStream
public abstract class IndexInput extends DataInput implements java.lang.Cloneable, java.io.Closeable
Abstract base class for input from a file in aDirectory. A random-access input stream. Used for all Lucene index input operations.IndexInputmay only be used from one thread, because it is not thread safe (it keeps internal state like file position). To allow multithreaded use, everyIndexInputinstance must be cloned before used in another thread. Subclasses must therefore implementclone(), returning a newIndexInputwhich operates on the same underlying resource, but positioned independently. Lucene never closes clonedIndexInputs, it will only do this on the original one. The original instance must take care that cloned instances throwAlreadyClosedExceptionwhen the original one is closed.- See Also:
Directory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description IndexInputclone()Returns a clone of this stream.abstract voidclose()Closes the stream to further operations.abstract longgetFilePointer()Returns 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.java.lang.StringtoString()-
Methods inherited from class org.apache.lucene.store.DataInput
readByte, readBytes, readBytes, readInt, readLong, readShort, readString, readStringSet, readStringStringMap, readVInt, readVLong
-
-
-
-
Method Detail
-
close
public abstract void close() throws java.io.IOExceptionCloses the stream to further operations.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getFilePointer
public abstract long getFilePointer()
Returns the current position in this file, where the next read will occur.- See Also:
seek(long)
-
seek
public abstract void seek(long pos) throws java.io.IOExceptionSets current position in this file, where the next read will occur.- Throws:
java.io.IOException- See Also:
getFilePointer()
-
length
public abstract long length()
The number of bytes in the file.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clone
public IndexInput 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.
-
-