public abstract class IndexInput extends DataInput implements ,
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
it is used in another thread. Subclasses must therefore implement clone()
,
returning a new IndexInput
which operates on the same underlying
resource, but positioned independently.
Warning: Lucene never closes cloned
IndexInput
s, it will only call close()
on the original object.
If you access the cloned IndexInput after closing the original object,
any readXXX
methods will throw AlreadyClosedException
.
Directory
Modifier | Constructor and Description |
---|---|
protected |
resourceDescription)
resourceDescription should be a non-null, opaque string
describing this resource; it's returned from
toString() . |
Modifier and Type | Method and Description |
---|---|
IndexInput |
clone()
Returns a clone of this stream.
|
abstract void |
close()
Closes the stream to further operations.
|
abstract long |
getFilePointer()
Returns the current position in this file, where the next read will
occur.
|
protected |
sliceDescription)
Subclasses call this to get the String for resourceDescription of a slice of this
IndexInput . |
abstract long |
length()
The number of bytes in the file.
|
RandomAccessInput |
randomAccessSlice(long offset,
long length)
Creates a random-access slice of this index input, with the given offset and length.
|
abstract void |
seek(long pos)
Sets current position in this file, where the next read will occur.
|
abstract IndexInput |
sliceDescription,
long offset,
long length)
Creates a slice of this index input, with the given description, offset, and length.
|
|
toString() |
readByte, readBytes, readBytes, readInt, readLELongs, readLong, readMapOfStrings, readSetOfStrings, readShort, readString, readVInt, readVLong, readZInt, readZLong, skipBytes
protected IndexInput( resourceDescription)
toString()
.public abstract void close() throws
in interface
in interface
public abstract long getFilePointer()
seek(long)
public abstract void seek(long pos) throws
EOFException
and then the
stream is in an undetermined state.
getFilePointer()
public abstract long length()
public toString()
in class
public IndexInput clone()
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 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.
public abstract sliceDescription, long offset, long length) throws
protected getFullSliceDescription( sliceDescription)
IndexInput
.public RandomAccessInput randomAccessSlice(long offset, long length) throws
The default implementation calls slice(java.lang.String, long, long)
, and it doesn't support random access,
it implements absolute reads as seek+read.
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.