public abstract class CustomBufferedIndexInput extends IndexInput
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buffer |
static int |
BUFFER_SIZE |
Constructor and Description |
---|
CustomBufferedIndexInput(String resourceDesc) |
CustomBufferedIndexInput(String resourceDesc,
int bufferSize) |
Modifier and Type | Method and Description |
---|---|
IndexInput |
clone()
Returns a clone of this stream.
|
void |
close()
Closes the stream to further operations.
|
protected abstract void |
closeInternal() |
protected int |
flushBuffer(IndexOutput out,
long numBytes)
Flushes the in-memory bufer to the given output, copying at most
numBytes . |
long |
getFilePointer()
Returns the current position in this file, where the next read will
occur.
|
byte |
readByte()
Reads and returns a single byte.
|
void |
readBytes(byte[] b,
int offset,
int len)
Reads a specified number of bytes into an array at the specified offset.
|
void |
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).
|
int |
readInt()
Reads four bytes and returns an int.
|
protected abstract void |
readInternal(byte[] b,
int offset,
int length)
Expert: implements buffer refill.
|
long |
readLong()
Reads eight bytes and returns a long.
|
int |
readVInt()
Reads an int stored in variable-length format.
|
long |
readVLong()
Reads a long stored in variable-length format.
|
void |
seek(long pos)
Sets current position in this file, where the next read will occur.
|
protected abstract void |
seekInternal(long pos)
Expert: implements seek.
|
IndexInput |
slice(String sliceDescription,
long offset,
long length)
Creates a slice of this index input, with the given description, offset, and length.
|
getFullSliceDescription, length, randomAccessSlice, toString
readMapOfStrings, readSetOfStrings, readShort, readString, readStringSet, readStringStringMap, readZInt, readZLong, skipBytes
public static final int BUFFER_SIZE
protected byte[] buffer
public CustomBufferedIndexInput(String resourceDesc)
public CustomBufferedIndexInput(String resourceDesc, int bufferSize)
public byte readByte() throws IOException
DataInput
readByte
in class DataInput
IOException
DataOutput.writeByte(byte)
public void readBytes(byte[] b, int offset, int len) throws IOException
DataInput
readBytes
in class DataInput
b
- the array to read bytes intooffset
- the offset in the array to start storing byteslen
- the number of bytes to readIOException
DataOutput.writeBytes(byte[],int)
public void readBytes(byte[] b, int offset, int len, boolean useBuffer) throws IOException
DataInput
BufferedIndexInput
respects this parameter.readBytes
in class DataInput
b
- the array to read bytes intooffset
- the offset in the array to start storing byteslen
- the number of bytes to readuseBuffer
- set to false if the caller will handle
buffering.IOException
DataOutput.writeBytes(byte[],int)
public int readInt() throws IOException
DataInput
readInt
in class DataInput
IOException
DataOutput.writeInt(int)
public long readLong() throws IOException
DataInput
readLong
in class DataInput
IOException
DataOutput.writeLong(long)
public int readVInt() throws IOException
DataInput
The format is described further in DataOutput.writeVInt(int)
.
readVInt
in class DataInput
IOException
DataOutput.writeVInt(int)
public long readVLong() throws IOException
DataInput
The format is described further in DataOutput.writeVInt(int)
.
readVLong
in class DataInput
IOException
DataOutput.writeVLong(long)
public final void close() throws IOException
IndexInput
close
in interface Closeable
close
in interface AutoCloseable
close
in class IndexInput
IOException
protected abstract void closeInternal() throws IOException
IOException
protected abstract void readInternal(byte[] b, int offset, int length) throws IOException
b
- the array to read bytes intooffset
- the offset in the array to start storing byteslength
- the number of bytes to readIOException
public long getFilePointer()
IndexInput
getFilePointer
in class IndexInput
IndexInput.seek(long)
public void seek(long pos) throws IOException
IndexInput
EOFException
and then the
stream is in an undetermined state.seek
in class IndexInput
IOException
IndexInput.getFilePointer()
protected abstract void seekInternal(long pos) throws IOException
readInternal(byte[],int,int)
will occur.IOException
readInternal(byte[],int,int)
public IndexInput clone()
IndexInput
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 IndexInput.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.
clone
in class IndexInput
public IndexInput slice(String sliceDescription, long offset, long length) throws IOException
IndexInput
slice
in class IndexInput
IOException
protected int flushBuffer(IndexOutput out, long numBytes) throws IOException
numBytes
.
NOTE: this method does not refill the buffer, however it does advance the buffer position.
IOException