public abstract class BufferedIndexInput extends IndexInput implements RandomAccessInput
IndexInput.| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buffer |
static int |
BUFFER_SIZE
Default buffer size set to 1024.
|
static int |
MERGE_BUFFER_SIZE
A buffer size for merges set to 4096.
|
static int |
MIN_BUFFER_SIZE
Minimum buffer size allowed
|
| Constructor and Description |
|---|
BufferedIndexInput(java.lang.String resourceDesc) |
BufferedIndexInput(java.lang.String resourceDesc,
int bufferSize)
Inits BufferedIndexInput with a specific bufferSize
|
BufferedIndexInput(java.lang.String resourceDesc,
IOContext context) |
| Modifier and Type | Method and Description |
|---|---|
static int |
bufferSize(IOContext context)
Returns default buffer sizes for the given
IOContext |
BufferedIndexInput |
clone()
Returns a clone of this stream.
|
protected int |
flushBuffer(IndexOutput out,
long numBytes)
Flushes the in-memory buffer 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.
|
byte |
readByte(long pos)
Reads a byte at the given position in the file
|
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.
|
int |
readInt(long pos)
Reads an integer at the given position in the file
|
protected abstract void |
readInternal(byte[] b,
int offset,
int length)
Expert: implements buffer refill.
|
long |
readLong()
Reads eight bytes and returns a long.
|
long |
readLong(long pos)
Reads a long at the given position in the file
|
short |
readShort()
Reads two bytes and returns a short.
|
short |
readShort(long pos)
Reads a short at the given position in the file
|
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
|
IndexInput |
slice(java.lang.String sliceDescription,
long offset,
long length)
Creates a slice of this index input, with the given description, offset, and length.
|
static BufferedIndexInput |
wrap(java.lang.String sliceDescription,
IndexInput other,
long offset,
long length)
Wraps a portion of another IndexInput with buffering.
|
close, getFullSliceDescription, length, randomAccessSlice, toStringreadMapOfStrings, readSetOfStrings, readString, readZInt, readZLong, skipBytespublic static final int BUFFER_SIZE
public static final int MIN_BUFFER_SIZE
public static final int MERGE_BUFFER_SIZE
protected byte[] buffer
public BufferedIndexInput(java.lang.String resourceDesc)
public BufferedIndexInput(java.lang.String resourceDesc,
IOContext context)
public BufferedIndexInput(java.lang.String resourceDesc,
int bufferSize)
public final byte readByte()
throws java.io.IOException
DataInputreadByte in class DataInputjava.io.IOExceptionDataOutput.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 java.io.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 readjava.io.IOExceptionDataOutput.writeBytes(byte[],int)public final void readBytes(byte[] b,
int offset,
int len,
boolean useBuffer)
throws java.io.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.java.io.IOExceptionDataOutput.writeBytes(byte[],int)public final short readShort()
throws java.io.IOException
DataInputreadShort in class DataInputjava.io.IOExceptionDataOutput.writeByte(byte)public final int readInt()
throws java.io.IOException
DataInputreadInt in class DataInputjava.io.IOExceptionDataOutput.writeInt(int)public final long readLong()
throws java.io.IOException
DataInputreadLong in class DataInputjava.io.IOExceptionDataOutput.writeLong(long)public final int readVInt()
throws java.io.IOException
DataInput
The format is described further in DataOutput.writeVInt(int).
readVInt in class DataInputjava.io.IOExceptionDataOutput.writeVInt(int)public final long readVLong()
throws java.io.IOException
DataInput
The format is described further in DataOutput.writeVInt(int).
readVLong in class DataInputjava.io.IOExceptionDataOutput.writeVLong(long)public final byte readByte(long pos)
throws java.io.IOException
RandomAccessInputreadByte in interface RandomAccessInputjava.io.IOExceptionDataInput.readByte()public final short readShort(long pos)
throws java.io.IOException
RandomAccessInputreadShort in interface RandomAccessInputjava.io.IOExceptionDataInput.readShort()public final int readInt(long pos)
throws java.io.IOException
RandomAccessInputreadInt in interface RandomAccessInputjava.io.IOExceptionDataInput.readInt()public final long readLong(long pos)
throws java.io.IOException
RandomAccessInputreadLong in interface RandomAccessInputjava.io.IOExceptionDataInput.readLong()protected abstract void readInternal(byte[] b,
int offset,
int length)
throws java.io.IOException
b - the array to read bytes intooffset - the offset in the array to start storing byteslength - the number of bytes to readjava.io.IOExceptionpublic final long getFilePointer()
IndexInputgetFilePointer in class IndexInputIndexInput.seek(long)public final void seek(long pos)
throws java.io.IOException
IndexInputEOFException and then the
stream is in an undetermined state.seek in class IndexInputjava.io.IOExceptionIndexInput.getFilePointer()protected abstract void seekInternal(long pos)
throws java.io.IOException
readInternal(byte[],int,int) will occur.java.io.IOExceptionreadInternal(byte[],int,int)public BufferedIndexInput clone()
IndexInputClones 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
IndexInputs, 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 IndexInputpublic IndexInput slice(java.lang.String sliceDescription, long offset, long length) throws java.io.IOException
IndexInputslice in class IndexInputjava.io.IOExceptionprotected final int flushBuffer(IndexOutput out, long numBytes) throws java.io.IOException
numBytes.
NOTE: this method does not refill the buffer, however it does advance the buffer position.
java.io.IOExceptionpublic static int bufferSize(IOContext context)
IOContextpublic static BufferedIndexInput wrap(java.lang.String sliceDescription, IndexInput other, long offset, long length)
Please note: This is in most cases ineffective, because it may double buffer!
Copyright © 2000–2025 The Apache Software Foundation. All rights reserved.