- java.lang.Object
-
- org.apache.lucene.store.DataInput
-
- org.apache.lucene.store.IndexInput
-
- org.apache.lucene.store.ChecksumIndexInput
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Cloneable
- Direct Known Subclasses:
BufferedChecksumIndexInput
,EndiannessReverserChecksumIndexInput
public abstract class ChecksumIndexInput extends IndexInput
Extension of IndexInput, computing checksum as it goes. Callers can retrieve the checksum viagetChecksum()
.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
SKIP_BUFFER_SIZE
private byte[]
skipBuffer
-
Constructor Summary
Constructors Modifier Constructor Description protected
ChecksumIndexInput(java.lang.String resourceDescription)
resourceDescription should be a non-null, opaque string describing this resource; it's returned fromIndexInput.toString()
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract long
getChecksum()
Returns the current checksum valuevoid
seek(long pos)
Sets current position in this file, where the next read will occur.private void
skipByReading(long numBytes)
Skip overnumBytes
bytes.-
Methods inherited from class org.apache.lucene.store.IndexInput
clone, close, getFilePointer, getFullSliceDescription, length, randomAccessSlice, skipBytes, slice, toString
-
Methods inherited from class org.apache.lucene.store.DataInput
readByte, readBytes, readBytes, readFloats, readInt, readInts, readLong, readLongs, readMapOfStrings, readSetOfStrings, readShort, readString, readVInt, readVLong, readZInt, readZLong
-
-
-
-
Field Detail
-
SKIP_BUFFER_SIZE
private static final int SKIP_BUFFER_SIZE
- See Also:
- Constant Field Values
-
skipBuffer
private byte[] skipBuffer
-
-
Constructor Detail
-
ChecksumIndexInput
protected ChecksumIndexInput(java.lang.String resourceDescription)
resourceDescription should be a non-null, opaque string describing this resource; it's returned fromIndexInput.toString()
.
-
-
Method Detail
-
getChecksum
public abstract long getChecksum() throws java.io.IOException
Returns the current checksum value- Throws:
java.io.IOException
-
seek
public void seek(long pos) throws java.io.IOException
Sets current position in this file, where the next read will occur. If this is beyond the end of the file then this will throwEOFException
and then the stream is in an undetermined state.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.- Specified by:
seek
in classIndexInput
- Throws:
java.io.IOException
- See Also:
IndexInput.getFilePointer()
-
skipByReading
private void skipByReading(long numBytes) throws java.io.IOException
Skip overnumBytes
bytes. The contract on this method is that it should have the same behavior as reading the same number of bytes into a buffer and discarding its content. Negative values ofnumBytes
are not supported.- Throws:
java.io.IOException
-
-