public final class ByteBuffersDataInput extends DataInput implements Accountable, RandomAccessInput
| Modifier and Type | Field and Description |
|---|---|
private int |
blockBits |
private int |
blockMask |
private java.nio.ByteBuffer[] |
blocks |
private long |
offset |
private long |
pos |
private long |
size |
| Constructor and Description |
|---|
ByteBuffersDataInput(java.util.List<java.nio.ByteBuffer> buffers)
Read data from a set of contiguous buffers.
|
| Modifier and Type | Method and Description |
|---|---|
private int |
blockIndex(long pos) |
private int |
blockOffset(long pos) |
private int |
blockSize() |
(package private) static int |
determineBlockPage(java.util.List<java.nio.ByteBuffer> buffers) |
private static void |
ensureAssumptions(java.util.List<java.nio.ByteBuffer> buffers) |
private static boolean |
isPowerOfTwo(int v) |
long |
position() |
long |
ramBytesUsed()
Return the memory usage of this object in bytes.
|
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[] arr,
int off,
int len)
Reads a specified number of bytes into an array at the specified offset.
|
void |
readBytes(java.nio.ByteBuffer buffer,
int len)
Reads exactly
len bytes into the given buffer. |
int |
readInt(long pos)
Reads an integer at the given position in the file
|
long |
readLong(long pos)
Reads a long at the given position in the file
|
short |
readShort(long pos)
Reads a short at the given position in the file
|
void |
seek(long position) |
long |
size() |
ByteBuffersDataInput |
slice(long offset,
long length) |
private static java.util.List<java.nio.ByteBuffer> |
sliceBufferList(java.util.List<java.nio.ByteBuffer> buffers,
long offset,
long length) |
java.lang.String |
toString() |
clone, readBytes, readInt, readLELongs, readLong, readMapOfStrings, readSetOfStrings, readShort, readString, readVInt, readVLong, readZInt, readZLong, skipBytesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetChildResourcesprivate final java.nio.ByteBuffer[] blocks
private final int blockBits
private final int blockMask
private final long size
private final long offset
private long pos
public ByteBuffersDataInput(java.util.List<java.nio.ByteBuffer> buffers)
public long size()
public long ramBytesUsed()
AccountableramBytesUsed in interface Accountablepublic byte readByte()
throws java.io.EOFException
DataInputreadByte in class DataInputjava.io.EOFExceptionDataOutput.writeByte(byte)public void readBytes(java.nio.ByteBuffer buffer,
int len)
throws java.io.EOFException
len bytes into the given buffer. The buffer must have
enough remaining limit.
If there are fewer than len bytes in the input, EOFException
is thrown.java.io.EOFExceptionpublic void readBytes(byte[] arr,
int off,
int len)
throws java.io.EOFException
DataInputreadBytes in class DataInputarr - the array to read bytes intooff - the offset in the array to start storing byteslen - the number of bytes to readjava.io.EOFExceptionDataOutput.writeBytes(byte[],int)public byte readByte(long pos)
RandomAccessInputreadByte in interface RandomAccessInputDataInput.readByte()public short readShort(long pos)
RandomAccessInputreadShort in interface RandomAccessInputDataInput.readShort()public int readInt(long pos)
RandomAccessInputreadInt in interface RandomAccessInputDataInput.readInt()public long readLong(long pos)
RandomAccessInputreadLong in interface RandomAccessInputDataInput.readLong()public long position()
public void seek(long position)
throws java.io.EOFException
java.io.EOFExceptionpublic ByteBuffersDataInput slice(long offset, long length)
public java.lang.String toString()
toString in class java.lang.Objectprivate final int blockIndex(long pos)
private final int blockOffset(long pos)
private int blockSize()
private static final boolean isPowerOfTwo(int v)
private static void ensureAssumptions(java.util.List<java.nio.ByteBuffer> buffers)
static int determineBlockPage(java.util.List<java.nio.ByteBuffer> buffers)
private static java.util.List<java.nio.ByteBuffer> sliceBufferList(java.util.List<java.nio.ByteBuffer> buffers,
long offset,
long length)