public abstract class BufferedIndexInput extends IndexInput
IndexInput.| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buffer |
static int |
BUFFER_SIZE
Default buffer size
|
| Constructor and Description |
|---|
BufferedIndexInput()
Deprecated.
please pass resourceDesc
|
BufferedIndexInput(int bufferSize)
Deprecated.
please pass resourceDesc
|
BufferedIndexInput(String resourceDesc) |
BufferedIndexInput(String resourceDesc,
int bufferSize)
Inits BufferedIndexInput with a specific bufferSize
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Returns a clone of this stream.
|
void |
copyBytes(IndexOutput out,
long numBytes)
Copies
numBytes bytes to the given IndexOutput. |
protected int |
flushBuffer(IndexOutput out,
long numBytes)
Flushes the in-memory bufer to the given output, copying at most
numBytes. |
int |
getBufferSize()
Returns buffer size.
|
long |
getFilePointer()
Returns the current position in this file, where the next read will
occur.
|
protected void |
newBuffer(byte[] newBuffer) |
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.
|
short |
readShort()
Reads two bytes and returns a short.
|
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.
|
void |
setBufferSize(int newSize)
Change the buffer size used by this IndexInput
|
close, length, skipChars, toStringreadChars, readString, readStringStringMap, setModifiedUTF8StringsModepublic static final int BUFFER_SIZE
protected byte[] buffer
@Deprecated public BufferedIndexInput()
public BufferedIndexInput(String resourceDesc)
@Deprecated public BufferedIndexInput(int bufferSize)
public BufferedIndexInput(String resourceDesc, int bufferSize)
public final byte readByte()
throws IOException
DataInputreadByte in class DataInputIOExceptionDataOutput.writeByte(byte)public final void setBufferSize(int newSize)
protected void newBuffer(byte[] newBuffer)
public final int getBufferSize()
public final void readBytes(byte[] b,
int offset,
int len)
throws IOException
DataInputreadBytes in class DataInputb - the array to read bytes intooffset - the offset in the array to start storing byteslen - the number of bytes to readIOExceptionDataOutput.writeBytes(byte[],int)public final void readBytes(byte[] b,
int offset,
int len,
boolean useBuffer)
throws IOException
DataInputBufferedIndexInput respects this parameter.readBytes in class DataInputb - 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.IOExceptionDataOutput.writeBytes(byte[],int)public final short readShort()
throws IOException
DataInputreadShort in class DataInputIOExceptionDataOutput.writeByte(byte)public final int readInt()
throws IOException
DataInputreadInt in class DataInputIOExceptionDataOutput.writeInt(int)public final long readLong()
throws IOException
DataInputreadLong in class DataInputIOExceptionDataOutput.writeLong(long)public final int readVInt()
throws IOException
DataInputreadVInt in class DataInputIOExceptionDataOutput.writeVInt(int)public final long readVLong()
throws IOException
DataInputreadVLong in class DataInputIOExceptionprotected 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 readIOExceptionpublic final long getFilePointer()
IndexInputgetFilePointer in class IndexInputIndexInput.seek(long)public final void seek(long pos)
throws IOException
IndexInputseek in class IndexInputIOExceptionIndexInput.getFilePointer()protected abstract void seekInternal(long pos)
throws IOException
readInternal(byte[],int,int) will occur.IOExceptionreadInternal(byte[],int,int)public Object clone()
DataInputClones 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.
protected final int flushBuffer(IndexOutput out, long numBytes) throws IOException
numBytes.
NOTE: this method does not refill the buffer, however it does advance the buffer position.
IOExceptionpublic void copyBytes(IndexOutput out, long numBytes) throws IOException
IndexInputnumBytes bytes to the given IndexOutput.
NOTE: this method uses an intermediate buffer to copy the bytes. Consider overriding it in your implementation, if you can make a better, optimized copy.
NOTE ensure that there are enough bytes in the input to copy to output. Otherwise, different exceptions may be thrown, depending on the implementation.
copyBytes in class IndexInputIOException