public abstract class Buffer extends BaseBuffer
com.yahoo.memory| Modifier and Type | Method and Description |
|---|---|
abstract Memory |
asMemory()
Convert this Buffer to a Memory.
|
void |
checkValidAndBounds(long offsetBytes,
long lengthBytes)
Checks that the specified range of bytes is within bounds of this object, throws
IllegalArgumentException if it's not: i. |
abstract int |
compareTo(long thisOffsetBytes,
long thisLengthBytes,
Buffer that,
long thatOffsetBytes,
long thatLengthBytes)
Compares the bytes of this Buffer to that Buffer.
|
abstract Buffer |
duplicate()
Returns a read-only duplicate view of this Buffer with the same but independent values of
start, position and end.
|
abstract Buffer |
duplicate(ByteOrder byteOrder)
Returns a read-only duplicate view of this Buffer with the same but independent values of
start, position and end, but with the specified byteOrder.
|
boolean |
equals(Object that)
Returns true if the given object is an instance of this class and has equal data contents.
|
boolean |
equalTo(long thisOffsetBytes,
Object that,
long thatOffsetBytes,
long lengthBytes)
Returns true if the given object is an instance of this class and has equal contents to
this object in the given range of bytes.
|
abstract boolean |
getBoolean()
Gets the boolean value at the current position.
|
abstract boolean |
getBoolean(long offsetBytes)
Gets the boolean value at the given offset.
|
abstract void |
getBooleanArray(boolean[] dstArray,
int dstOffsetBooleans,
int lengthBooleans)
Gets the boolean array at the current position.
|
abstract byte |
getByte()
Gets the byte value at the current position.
|
abstract byte |
getByte(long offsetBytes)
Gets the byte value at the given offset.
|
abstract void |
getByteArray(byte[] dstArray,
int dstOffsetBytes,
int lengthBytes)
Gets the byte array at the current position.
|
ByteBuffer |
getByteBuffer()
Gets the backing ByteBuffer if it exists, otherwise returns null.
|
ByteOrder |
getByteOrder()
Gets the current ByteOrder.
|
long |
getCapacity()
Gets the capacity of this object in bytes
|
abstract char |
getChar()
Gets the char value at the current position.
|
abstract char |
getChar(long offsetBytes)
Gets the char value at the given offset.
|
abstract void |
getCharArray(char[] dstArray,
int dstOffsetChars,
int lengthChars)
Gets the char array at the current position.
|
long |
getCumulativeOffset()
Gets the cumulative offset in bytes of this object from the backing resource.
|
long |
getCumulativeOffset(long offsetBytes)
Gets the cumulative offset in bytes of this object from the backing resource including the given
offsetBytes.
|
static long |
getCurrentDirectMemoryAllocated()
Gets the current size of active direct memory allocated.
|
static long |
getCurrentDirectMemoryAllocations()
Gets the current number of active direct memory allocations.
|
static long |
getCurrentDirectMemoryMapAllocated()
Gets the current size of active direct memory map allocated.
|
static long |
getCurrentDirectMemoryMapAllocations()
Gets the current number of active direct memory map allocations.
|
abstract double |
getDouble()
Gets the double value at the current position.
|
abstract double |
getDouble(long offsetBytes)
Gets the double value at the given offset.
|
abstract void |
getDoubleArray(double[] dstArray,
int dstOffsetDoubles,
int lengthDoubles)
Gets the double array at the current position.
|
abstract float |
getFloat()
Gets the float value at the current position.
|
abstract float |
getFloat(long offsetBytes)
Gets the float value at the given offset.
|
abstract void |
getFloatArray(float[] dstArray,
int dstOffsetFloats,
int lengthFloats)
Gets the float array at the current position.
|
abstract int |
getInt()
Gets the int value at the current position.
|
abstract int |
getInt(long offsetBytes)
Gets the int value at the given offset.
|
abstract void |
getIntArray(int[] dstArray,
int dstOffsetInts,
int lengthInts)
Gets the int array at the current position.
|
abstract long |
getLong()
Gets the long value at the current position.
|
abstract long |
getLong(long offsetBytes)
Gets the long value at the given offset.
|
abstract void |
getLongArray(long[] dstArray,
int dstOffsetLongs,
int lengthLongs)
Gets the long array at the current position.
|
long |
getRegionOffset()
Returns the offset of address zero of this object relative to the address zero of the
backing resource but not including the size of any Java object header.
|
long |
getRegionOffset(long offsetBytes)
Returns the offset of address zero of this object relative to the address zero of the
backing resource plus the given offsetBytes but not including the size of any Java object
header.
|
abstract short |
getShort()
Gets the short value at the current position.
|
abstract short |
getShort(long offsetBytes)
Gets the short value at the given offset.
|
abstract void |
getShortArray(short[] dstArray,
int dstOffsetShorts,
int lengthShorts)
Gets the short array at the current position.
|
boolean |
hasArray()
Returns true if this object is backed by an on-heap primitive array
|
boolean |
hasByteBuffer()
Returns true if this Memory is backed by a ByteBuffer.
|
int |
hashCode()
Returns the hashCode of this object.
|
boolean |
isDirect()
Returns true if the backing resource is direct (off-heap) memory.
|
boolean |
isNativeOrder()
Returns true if the current byte order is native order.
|
boolean |
isReadOnly()
Returns true if this object or the backing resource is read-only.
|
boolean |
isSameResource(Object that)
Returns true if the backing resource of this is identical with the backing resource
of that.
|
boolean |
isValid()
Returns true if this object is valid and has not been closed.
|
abstract Buffer |
region()
A region is a read-only view of this object.
|
abstract Buffer |
region(long offsetBytes,
long capacityBytes,
ByteOrder byteOrder)
A region is a read-only view of this object.
|
String |
toHexString(String header,
long offsetBytes,
int lengthBytes)
Returns a formatted hex string of a range of this object.
|
static Buffer |
wrap(ByteBuffer byteBuf)
Accesses the given ByteBuffer for read-only operations.
|
static Buffer |
wrap(ByteBuffer byteBuf,
ByteOrder byteOrder)
Accesses the given ByteBuffer for read-only operations.
|
long |
xxHash64(long offsetBytes,
long lengthBytes,
long seed)
Returns the 64-bit hash of the sequence of bytes in this object specified by
offsetBytes, lengthBytes and a seed.
|
getEnd, getPosition, getRemaining, getStart, hasRemaining, incrementAndCheckPosition, incrementPosition, resetPosition, setAndCheckPosition, setAndCheckStartPositionEnd, setPosition, setStartPositionEndpublic static Buffer wrap(ByteBuffer byteBuf)
byteBuf - the given ByteBuffer, must not be null.public static Buffer wrap(ByteBuffer byteBuf, ByteOrder byteOrder)
byteBuf - the given ByteBuffer, must not be nullbyteOrder - the byte order to be used, which may be independent of the byte order
state of the given ByteBufferpublic abstract Buffer duplicate()
public abstract Buffer duplicate(ByteOrder byteOrder)
byteOrder - the given ByteOrder.public abstract Buffer region()
public abstract Buffer region(long offsetBytes, long capacityBytes, ByteOrder byteOrder)
Note: The Memory returned with asMemory() will have the originating Memory byte order.
offsetBytes - the starting offset with respect to the origin of this WritableBuffercapacityBytes - the capacity of the returned region in bytesbyteOrder - the given byte orderpublic abstract Memory asMemory()
public abstract boolean getBoolean()
public abstract boolean getBoolean(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startpublic abstract void getBooleanArray(boolean[] dstArray,
int dstOffsetBooleans,
int lengthBooleans)
dstArray - The preallocated destination array.dstOffsetBooleans - offset in array unitslengthBooleans - number of array units to transferpublic abstract byte getByte()
public abstract byte getByte(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startpublic abstract void getByteArray(byte[] dstArray,
int dstOffsetBytes,
int lengthBytes)
dstArray - The preallocated destination array.dstOffsetBytes - offset in array unitslengthBytes - number of array units to transferpublic abstract char getChar()
public abstract char getChar(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startpublic abstract void getCharArray(char[] dstArray,
int dstOffsetChars,
int lengthChars)
dstArray - The preallocated destination array.dstOffsetChars - offset in array unitslengthChars - number of array units to transferpublic abstract double getDouble()
public abstract double getDouble(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startpublic abstract void getDoubleArray(double[] dstArray,
int dstOffsetDoubles,
int lengthDoubles)
dstArray - The preallocated destination array.dstOffsetDoubles - offset in array unitslengthDoubles - number of array units to transferpublic abstract float getFloat()
public abstract float getFloat(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startpublic abstract void getFloatArray(float[] dstArray,
int dstOffsetFloats,
int lengthFloats)
dstArray - The preallocated destination array.dstOffsetFloats - offset in array unitslengthFloats - number of array units to transferpublic abstract int getInt()
public abstract int getInt(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startpublic abstract void getIntArray(int[] dstArray,
int dstOffsetInts,
int lengthInts)
dstArray - The preallocated destination array.dstOffsetInts - offset in array unitslengthInts - number of array units to transferpublic abstract long getLong()
public abstract long getLong(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startpublic abstract void getLongArray(long[] dstArray,
int dstOffsetLongs,
int lengthLongs)
dstArray - The preallocated destination array.dstOffsetLongs - offset in array unitslengthLongs - number of array units to transferpublic abstract short getShort()
public abstract short getShort(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startpublic abstract void getShortArray(short[] dstArray,
int dstOffsetShorts,
int lengthShorts)
dstArray - The preallocated destination array.dstOffsetShorts - offset in array unitslengthShorts - number of array units to transferpublic abstract int compareTo(long thisOffsetBytes,
long thisLengthBytes,
Buffer that,
long thatOffsetBytes,
long thatLengthBytes)
thisOffsetBytes - the starting offset for this BufferthisLengthBytes - the length of the region to compare from this Bufferthat - the other Buffer to compare withthatOffsetBytes - the starting offset for that BufferthatLengthBytes - the length of the region to compare from that Bufferpublic final boolean equals(Object that)
public final boolean equalTo(long thisOffsetBytes,
Object that,
long thatOffsetBytes,
long lengthBytes)
thisOffsetBytes - the starting offset in bytes for this object.that - the given objectthatOffsetBytes - the starting offset in bytes for the given objectlengthBytes - the size of the range in bytespublic ByteBuffer getByteBuffer()
public final ByteOrder getByteOrder()
public final long getCapacity()
public final long getCumulativeOffset()
public final long getCumulativeOffset(long offsetBytes)
offsetBytes - offset to be added to the cumulative offset.public final long getRegionOffset()
public final long getRegionOffset(long offsetBytes)
offsetBytes - the given offsetBytespublic final boolean hasArray()
public final int hashCode()
The hash code of this object depends upon all of its contents. Because of this, it is inadvisable to use these objects as keys in hash maps or similar data structures unless it is known that their contents will not change.
If it is desirable to use these objects in a hash map depending only on object identity,
than the IdentityHashMap can be used.
public final long xxHash64(long offsetBytes,
long lengthBytes,
long seed)
offsetBytes - the given offset in bytes to the first byte of the byte sequence.lengthBytes - the given length in bytes of the byte sequence.seed - the given long seed.public final boolean hasByteBuffer()
public final boolean isDirect()
public final boolean isNativeOrder()
public final boolean isReadOnly()
public final boolean isSameResource(Object that)
that - A different non-null objectpublic boolean isValid()
public final void checkValidAndBounds(long offsetBytes,
long lengthBytes)
IllegalArgumentException if it's not: i. e. if offsetBytes < 0, or length < 0,
or offsetBytes + length > getCapacity().offsetBytes - the given offset in bytes of this objectlengthBytes - the given length in bytes of this objectpublic static final long getCurrentDirectMemoryAllocations()
public static final long getCurrentDirectMemoryAllocated()
public static final long getCurrentDirectMemoryMapAllocations()
public static final long getCurrentDirectMemoryMapAllocated()
public final String toHexString(String header, long offsetBytes, int lengthBytes)
header - a descriptive headeroffsetBytes - offset bytes relative to this object startlengthBytes - number of bytes to convert to a hex stringCopyright © 2015–2018 Yahoo! Inc.. All rights reserved.