public final class ByteBuffersIndexInput extends IndexInput implements RandomAccessInput
Modifier and Type | Field and Description |
---|---|
private ByteBuffersDataInput |
in |
Constructor and Description |
---|
ByteBuffersIndexInput(ByteBuffersDataInput in,
java.lang.String resourceDescription) |
Modifier and Type | Method and Description |
---|---|
IndexInput |
clone()
Returns a clone of this stream.
|
void |
close()
Closes the stream to further operations.
|
private void |
ensureOpen() |
long |
getFilePointer()
Returns the current position in this file, where the next read will
occur.
|
long |
length()
The number of bytes in the file.
|
RandomAccessInput |
randomAccessSlice(long offset,
long length)
Creates a random-access slice of this index input, with the given offset and length.
|
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
|
long |
readLong()
Reads eight bytes and returns a long.
|
long |
readLong(long pos)
Reads a long at the given position in the file
|
java.util.Map<java.lang.String,java.lang.String> |
readMapOfStrings()
Reads a Map<String,String> previously written
with
DataOutput.writeMapOfStrings(Map) . |
java.util.Set<java.lang.String> |
readSetOfStrings()
Reads a Set<String> previously written
with
DataOutput.writeSetOfStrings(Set) . |
short |
readShort()
Reads two bytes and returns a short.
|
short |
readShort(long pos)
Reads a short at the given position in the file
|
java.lang.String |
readString()
Reads a string.
|
int |
readVInt()
Reads an int stored in variable-length format.
|
long |
readVLong()
Reads a long stored in variable-length format.
|
int |
readZInt()
Read a
zig-zag -encoded
variable-length integer. |
long |
readZLong()
Read a
zig-zag -encoded
variable-length integer. |
void |
seek(long pos)
Sets current position in this file, where the next read will occur.
|
void |
skipBytes(long numBytes)
Skip over
numBytes bytes. |
ByteBuffersIndexInput |
slice(java.lang.String sliceDescription,
long offset,
long length)
Creates a slice of this index input, with the given description, offset, and length.
|
getFullSliceDescription, toString
private ByteBuffersDataInput in
public ByteBuffersIndexInput(ByteBuffersDataInput in, java.lang.String resourceDescription)
public void close() throws java.io.IOException
IndexInput
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class IndexInput
java.io.IOException
public long getFilePointer()
IndexInput
getFilePointer
in class IndexInput
IndexInput.seek(long)
public void seek(long pos) throws java.io.IOException
IndexInput
EOFException
and then the
stream is in an undetermined state.seek
in class IndexInput
java.io.IOException
IndexInput.getFilePointer()
public long length()
IndexInput
length
in class IndexInput
public ByteBuffersIndexInput slice(java.lang.String sliceDescription, long offset, long length) throws java.io.IOException
IndexInput
slice
in class IndexInput
java.io.IOException
public byte readByte() throws java.io.IOException
DataInput
readByte
in class DataInput
java.io.IOException
DataOutput.writeByte(byte)
public void readBytes(byte[] b, int offset, int len) throws java.io.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 readjava.io.IOException
DataOutput.writeBytes(byte[],int)
public RandomAccessInput randomAccessSlice(long offset, long length) throws java.io.IOException
IndexInput
The default implementation calls IndexInput.slice(java.lang.String, long, long)
, and it doesn't support random access,
it implements absolute reads as seek+read.
randomAccessSlice
in class IndexInput
java.io.IOException
public void readBytes(byte[] b, int offset, int len, boolean useBuffer) throws java.io.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.java.io.IOException
DataOutput.writeBytes(byte[],int)
public short readShort() throws java.io.IOException
DataInput
readShort
in class DataInput
java.io.IOException
DataOutput.writeByte(byte)
public int readInt() throws java.io.IOException
DataInput
readInt
in class DataInput
java.io.IOException
DataOutput.writeInt(int)
public int readVInt() throws java.io.IOException
DataInput
The format is described further in DataOutput.writeVInt(int)
.
readVInt
in class DataInput
java.io.IOException
DataOutput.writeVInt(int)
public int readZInt() throws java.io.IOException
DataInput
zig-zag
-encoded
variable-length
integer.readZInt
in class DataInput
java.io.IOException
DataOutput.writeZInt(int)
public long readLong() throws java.io.IOException
DataInput
readLong
in class DataInput
java.io.IOException
DataOutput.writeLong(long)
public long readVLong() throws java.io.IOException
DataInput
The format is described further in DataOutput.writeVInt(int)
.
readVLong
in class DataInput
java.io.IOException
DataOutput.writeVLong(long)
public long readZLong() throws java.io.IOException
DataInput
zig-zag
-encoded
variable-length
integer. Reads between one and ten
bytes.readZLong
in class DataInput
java.io.IOException
DataOutput.writeZLong(long)
public java.lang.String readString() throws java.io.IOException
DataInput
readString
in class DataInput
java.io.IOException
DataOutput.writeString(String)
public java.util.Map<java.lang.String,java.lang.String> readMapOfStrings() throws java.io.IOException
DataInput
DataOutput.writeMapOfStrings(Map)
.readMapOfStrings
in class DataInput
java.io.IOException
public java.util.Set<java.lang.String> readSetOfStrings() throws java.io.IOException
DataInput
DataOutput.writeSetOfStrings(Set)
.readSetOfStrings
in class DataInput
java.io.IOException
public void skipBytes(long numBytes) throws java.io.IOException
DataInput
numBytes
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 of numBytes
are not supported.public byte readByte(long pos) throws java.io.IOException
RandomAccessInput
readByte
in interface RandomAccessInput
java.io.IOException
DataInput.readByte()
public short readShort(long pos) throws java.io.IOException
RandomAccessInput
readShort
in interface RandomAccessInput
java.io.IOException
DataInput.readShort()
public int readInt(long pos) throws java.io.IOException
RandomAccessInput
readInt
in interface RandomAccessInput
java.io.IOException
DataInput.readInt()
public long readLong(long pos) throws java.io.IOException
RandomAccessInput
readLong
in interface RandomAccessInput
java.io.IOException
DataInput.readLong()
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
private void ensureOpen()