|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.io.AbstractFixedByteArrayBuffer
public abstract class AbstractFixedByteArrayBuffer
Efficient absolute get/put operations on a slice of a byte[]. This class is
not thread-safe under mutation because the operations are not atomic.
Concurrent operations on the same region of the slice can reveal partial
updates. This class is abstract. A concrete implementation need only
implement IByteArraySlice.array() and an appropriate constructor. This allows for
use cases where the backing byte[] is extensible. E.g., a fixed slice onto an
extensible ByteArrayBuffer.
| Constructor Summary | |
|---|---|
protected |
AbstractFixedByteArrayBuffer(int off,
int len)
Protected constructor used to create a slice. |
| Method Summary | |
|---|---|
ByteBuffer |
asByteBuffer()
Wraps the data in the slice within a ByteBuffer (does NOT copy
the data). |
void |
get(int srcoff,
byte[] dst)
Absolute bulk get copies dst.length bytes from the
specified offset into the slice defined by this buffer into the caller's
array. |
void |
get(int srcoff,
byte[] dst,
int dstoff,
int dstlen)
Absolute bulk get copies the specified slice of bytes from this buffer into the specified slice of the caller's array. |
boolean |
getBit(long bitIndex)
Get the value of a bit. |
byte |
getByte(int pos)
Absolute get for reading a byte value. |
DataInputBuffer |
getDataInput()
Return an input stream that will read from the slice. |
double |
getDouble(int pos)
|
float |
getFloat(int pos)
|
it.unimi.dsi.io.InputBitStream |
getInputBitStream()
Return a bit stream that will read from the slice. |
int |
getInt(int pos)
|
long |
getLong(int pos)
|
short |
getShort(int pos)
|
int |
len()
The length of the slice in the IByteArraySlice.array(). |
int |
off()
The start of the slice in the IByteArraySlice.array(). |
void |
put(int pos,
byte[] b)
Absolute bulk put copies all bytes in the caller's array into this buffer starting at the specified position within the slice defined by this buffer. |
void |
put(int dstoff,
byte[] src,
int srcoff,
int srclen)
Absolute bulk put copies the specified slice of bytes from the caller's array into this buffer starting at the specified position within the slice defined by this buffer. |
void |
putByte(int pos,
byte v)
Absolute put method for writing a byte value. |
void |
putDouble(int pos,
double d)
|
void |
putFloat(int pos,
float f)
|
void |
putInt(int pos,
int v)
|
void |
putLong(int pos,
long v)
|
void |
putShort(int pos,
short v)
|
protected boolean |
rangeCheck(int aoff,
int alen)
Verify that an operation starting at the specified offset into the slice and having the specified length is valid against the slice. |
boolean |
setBit(long bitIndex,
boolean value)
Set the value of a bit. |
AbstractFixedByteArrayBuffer |
slice(int aoff,
int alen)
Return a slice of the backing buffer. |
byte[] |
toByteArray()
Return a copy of the data in the slice. |
static FixedByteArrayBuffer |
wrap(byte[] array)
A slice wrapping the entire array. |
void |
writeOn(DataOutput out)
Write the slice on the output stream. |
void |
writeOn(OutputStream os)
Write the slice on the output stream. |
void |
writeOn(OutputStream os,
int aoff,
int alen)
Write part of the slice on the output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.bigdata.io.IByteArraySlice |
|---|
array |
| Constructor Detail |
|---|
protected AbstractFixedByteArrayBuffer(int off,
int len)
off - The offset of the start of the slice.len - The length of the slice.| Method Detail |
|---|
public final int off()
IByteArraySliceIByteArraySlice.array().
off in interface IByteArraySlicepublic final int len()
IByteArraySliceIByteArraySlice.array().
len in interface IByteArraySlicepublic static FixedByteArrayBuffer wrap(byte[] array)
array - The array.
protected boolean rangeCheck(int aoff,
int alen)
aoff - The offset into the slice.alen - The #of bytes to be addressed starting from that offset.
true.
IllegalArgumentException - if the operation is not valid.
public final void put(int pos,
byte[] b)
IDataRecord
put in interface IDataRecordpos - The starting position within the slice defined by this buffer.b - The source data.
public final void put(int dstoff,
byte[] src,
int srcoff,
int srclen)
IDataRecord
put in interface IDataRecorddstoff - The offset into the slice to which the data will be copied.src - The source data.srcoff - The offset of the 1st byte in the source data to be copied.srclen - The #of bytes to be copied.
public final void get(int srcoff,
byte[] dst)
IDataRecorddst.length bytes from the
specified offset into the slice defined by this buffer into the caller's
array.
get in interface IDataRecordsrcoff - The offset into the slice of the first byte to be copied.dst - The array into which the data will be copied.
public final void get(int srcoff,
byte[] dst,
int dstoff,
int dstlen)
IDataRecord
get in interface IDataRecordsrcoff - The offset into the slice defined by this buffer of the first
byte to be copied.dst - The array into which the data will be copied.dstoff - The offset of the first byte in that array onto which the data
will be copied.dstlen - The #of bytes to be copied.
public final void putByte(int pos,
byte v)
IDataRecord
putByte in interface IDataRecordpos - The offset into the slice.v - The value.public final byte getByte(int pos)
IDataRecord
getByte in interface IDataRecordpos - The offset into the slice.
public final void putShort(int pos,
short v)
putShort in interface IDataRecordpublic final short getShort(int pos)
getShort in interface IDataRecord
public final void putInt(int pos,
int v)
putInt in interface IDataRecordpublic final int getInt(int pos)
getInt in interface IDataRecord
public final void putFloat(int pos,
float f)
putFloat in interface IDataRecordpublic final float getFloat(int pos)
getFloat in interface IDataRecord
public final void putLong(int pos,
long v)
putLong in interface IDataRecord
public final void putDouble(int pos,
double d)
putDouble in interface IDataRecordpublic final long getLong(int pos)
getLong in interface IDataRecordpublic final double getDouble(int pos)
getDouble in interface IDataRecordpublic final boolean getBit(long bitIndex)
IDataRecord
getBit in interface IDataRecordbitIndex - The index of the bit, counting from the first bit position in
the slice.
public final boolean setBit(long bitIndex,
boolean value)
IDataRecord
setBit in interface IDataRecordbitIndex - The index of the bit, counting from the first bit position in
the slice.
public final byte[] toByteArray()
IDataRecord
toByteArray in interface IDataRecordIDataRecord.asByteBuffer()public final ByteBuffer asByteBuffer()
IDataRecordByteBuffer (does NOT copy
the data).
asByteBuffer in interface IDataRecordByteBuffer encapsulating a reference to the data in the
slice.
public AbstractFixedByteArrayBuffer slice(int aoff,
int alen)
IDataRecord
slice in interface IDataRecordaoff - The starting offset of the slice into this slice.alen - The #of bytes in the slice.
public DataInputBuffer getDataInput()
IFixedDataRecord
getDataInput in interface IFixedDataRecordpublic it.unimi.dsi.io.InputBitStream getInputBitStream()
IFixedDataRecord
Note: You DO NOT need to close this stream since it is backed by a
byte[]. In fact, InputBitStream.close() when backed by a byte[]
appears to have relatively high overhead, which is weird.
getInputBitStream in interface IFixedDataRecord
public final void writeOn(OutputStream os)
throws IOException
IFixedDataRecord
writeOn in interface IFixedDataRecordos - The output stream.
IOException
public final void writeOn(DataOutput out)
throws IOException
IFixedDataRecord
writeOn in interface IFixedDataRecordIOException
public final void writeOn(OutputStream os,
int aoff,
int alen)
throws IOException
IFixedDataRecord
writeOn in interface IFixedDataRecordos - The output stream.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||