Extension of IndexInput, computing checksum as it goes. Callers can retrieve the checksum via
#getChecksum().
getChecksum() · also: get_checksumReturns the current checksum value
seek(long pos)
ChecksumIndexInput can only seek forward and seeks are expensive since they imply to
read bytes in-between the current position and the target position in order to update the
checksum.
readByte()Reads and returns a single byte.
readBytes(byte[] b, int offset, int len)Reads a specified number of bytes into an array at the specified offset.
| name | type | description |
|---|---|---|
| b | byte[] | the array to read bytes into |
| offset | int | the offset in the array to start storing bytes |
| len | int | the number of bytes to read |
readBytes(byte[] b, int offset, int len, boolean useBuffer)Reads a specified number of bytes into an array at the specified offset with control over
whether the read should be buffered (callers who have their own buffer should pass in "false"
for useBuffer). Currently only BufferedIndexInput respects this parameter.
| name | type | description |
|---|---|---|
| b | byte[] | the array to read bytes into |
| offset | int | the offset in the array to start storing bytes |
| len | int | the number of bytes to read |
| use_buffer | boolean | set to false if the caller will handle buffering. |
readFloats(float[] floats, int offset, int len)Reads a specified number of floats into an array at the specified offset.
| name | type | description |
|---|---|---|
| floats | float[] | the array to read bytes into |
| offset | int | the offset in the array to start storing floats |
| len | int | the number of floats to read |
readGroupVInt(int[] dst, int offset)GroupVIntUtil#readGroupVInts(DataInput, int[], int) to decode a full group including tails
instead.
Legacy: This method allowed to implement GroupVInt encoding in a more efficient way when this implementation supports random access. It is no longer called by Lucene's code.
If you have implemented this method, simply remove it!
readInt()Reads four bytes and returns an int (LE byte order).
readInts(int[] dst, int offset, int length)Reads a specified number of ints into an array at the specified offset.
| name | type | description |
|---|---|---|
| dst | int[] | the array to read bytes into |
| offset | int | the offset in the array to start storing ints |
| length | int | the number of ints to read |
readLong()Reads eight bytes and returns a long (LE byte order).
readLongs(long[] dst, int offset, int length)Read a specified number of longs.
readMapOfStrings()Reads a Map<String,String> previously written with DataOutput#writeMapOfStrings(Map).
Returns: An immutable map containing the written contents.
readSetOfStrings()Reads a Set<String> previously written with DataOutput#writeSetOfStrings(Set).
Returns: An immutable set containing the written contents.
readShort()Reads two bytes and returns a short (LE byte order).
readString()Reads a string.
readVInt()Reads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are supported, but should be avoided.
The format is described further in DataOutput#writeVInt(int).
readVLong()Reads a long stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.
The format is described further in DataOutput#writeVInt(int).
readZInt()Read a zig-zag-encoded variable-length
integer.
readZLong()Read a zig-zag-encoded variable-length
integer. Reads between one and ten bytes.
Warning: Lucene never closes cloned IndexInputs, 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.
close()Closes the stream to further operations.
getFilePointer() · also: get_file_pointerReturns the current position in this file, where the next read will occur.
length()The number of bytes in the file.
isLoaded() · also: is_loadedReturns a hint whether all the contents of this input are resident in physical memory. It's a hint because the operating system may have paged out some of the data by the time this method returns. If the optional is true, then it's likely that the contents of this input are resident in physical memory. A value of false does not imply that the contents are not resident in physical memory. An empty optional is returned if it is not possible to determine.
This runs in linear time with the #length() of this input / page size.
The default implementation returns an empty optional.
prefetch(long offset, long length)Optional method: Give a hint to this input that some bytes will be read in the near future. IndexInput implementations may take advantage of this hint to start fetching pages of data immediately from storage.
The default implementation is a no-op.
| name | type | description |
|---|---|---|
| offset | long | start offset |
| length | long | the number of bytes to prefetch |
randomAccessSlice(long offset, long length)Creates a random-access slice of this index input, with the given offset and length.
The default implementation calls #slice, and it doesn't support random access, it
implements absolute reads as seek+read.
skipBytes(long numBytes)
Behavior is functionally equivalent to seeking to getFilePointer() + numBytes.
slice(String sliceDescription, long offset, long length)Creates a slice of this index input, with the given description, offset, and length. The slice is sought to the beginning.
slice(String sliceDescription, long offset, long length, org.apache.lucene.store.IOContext context)Create a slice with a new IOContext. This is typically used by CompoundFormat
implementations to modify the IOContext for specific files within the compound file.
NOTE: only certain IOContext may be usable here, depending on how this
instance was opened.
The default implementation delegates to #slice(String, long, long) and ignores the
IOContext.
toString()updateIOContext(org.apache.lucene.store.IOContext context)Optional method: Updates the IOContext to specify a new read access pattern. IndexInput
implementations may take advantage of this hint to optimize reads from storage.
The default implementation is a no-op.