public abstract class WritableBuffer extends Buffer
| Modifier and Type | Method and Description |
|---|---|
abstract WritableMemory |
asWritableMemory()
Convert this WritableBuffer to a WritableMemory.
|
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 void |
clear()
Clears all bytes of this Buffer from position to end to zero.
|
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 void |
fill(byte value)
Fills this Buffer from position to end with the given byte value.
|
abstract Object |
getArray()
Returns the primitive backing array, otherwise null.
|
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
|
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.
|
MemoryRequestServer |
getMemoryRequestServer()
For Direct Memory only.
|
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.
|
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 void |
putBoolean(boolean value)
Puts the boolean value at the current position.
|
abstract void |
putBoolean(long offsetBytes,
boolean value)
Puts the boolean value at the given offset.
|
abstract void |
putBooleanArray(boolean[] srcArray,
int srcOffsetBooleans,
int lengthBooleans)
Puts the boolean array at the current position.
|
abstract void |
putByte(byte value)
Puts the byte value at the current position.
|
abstract void |
putByte(long offsetBytes,
byte value)
Puts the byte value at the given offset.
|
abstract void |
putByteArray(byte[] srcArray,
int srcOffsetBytes,
int lengthBytes)
Puts the byte array at the current position.
|
abstract void |
putChar(char value)
Puts the char value at the current position.
|
abstract void |
putChar(long offsetBytes,
char value)
Puts the char value at the given offset.
|
abstract void |
putCharArray(char[] srcArray,
int srcOffsetChars,
int lengthChars)
Puts the char array at the current position.
|
abstract void |
putDouble(double value)
Puts the double value at the current position.
|
abstract void |
putDouble(long offsetBytes,
double value)
Puts the double value at the given offset.
|
abstract void |
putDoubleArray(double[] srcArray,
int srcOffsetDoubles,
int lengthDoubles)
Puts the double array at the current position.
|
abstract void |
putFloat(float value)
Puts the float value at the current position.
|
abstract void |
putFloat(long offsetBytes,
float value)
Puts the float value at the given offset.
|
abstract void |
putFloatArray(float[] srcArray,
int srcOffsetFloats,
int lengthFloats)
Puts the float array at the current position.
|
abstract void |
putInt(int value)
Puts the int value at the current position.
|
abstract void |
putInt(long offsetBytes,
int value)
Puts the int value at the given offset.
|
abstract void |
putIntArray(int[] srcArray,
int srcOffsetInts,
int lengthInts)
Puts the int array at the current position.
|
abstract void |
putLong(long value)
Puts the long value at the current position.
|
abstract void |
putLong(long offsetBytes,
long value)
Puts the long value at the given offset.
|
abstract void |
putLongArray(long[] srcArray,
int srcOffsetLongs,
int lengthLongs)
Puts the long array at the current position.
|
abstract void |
putShort(long offsetBytes,
short value)
Puts the short value at the given offset.
|
abstract void |
putShort(short value)
Puts the short value at the current position.
|
abstract void |
putShortArray(short[] srcArray,
int srcOffsetShorts,
int lengthShorts)
Puts the short array at the current position.
|
String |
toHexString(String header,
long offsetBytes,
int lengthBytes)
Returns a formatted hex string of a range of this object.
|
static WritableBuffer |
wrap(ByteBuffer byteBuf)
Accesses the given ByteBuffer for write operations.
|
static WritableBuffer |
wrap(ByteBuffer byteBuf,
ByteOrder byteOrder)
Accesses the given ByteBuffer for write operations.
|
abstract WritableBuffer |
writableDuplicate()
Returns a duplicate writable view of this Buffer with the same but independent values of
start, position and end.
|
abstract WritableBuffer |
writableDuplicate(ByteOrder byteOrder)
Returns a duplicate writable view of this Buffer with the same but independent values of
start, position and end, but with the specified byteOrder.
|
abstract WritableBuffer |
writableRegion()
A writable region is a writable view of this object.
|
abstract WritableBuffer |
writableRegion(long offsetBytes,
long capacityBytes,
ByteOrder byteOrder)
A writable region is a writable view of this object.
|
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.
|
asMemory, compareTo, duplicate, duplicate, getBoolean, getBoolean, getBooleanArray, getByte, getByte, getByteArray, getChar, getChar, getCharArray, getDouble, getDouble, getDoubleArray, getFloat, getFloat, getFloatArray, getInt, getInt, getIntArray, getLong, getLong, getLongArray, getShort, getShort, getShortArray, region, regiongetEnd, getPosition, getRemaining, getStart, hasRemaining, incrementAndCheckPosition, incrementPosition, resetPosition, setAndCheckPosition, setAndCheckStartPositionEnd, setPosition, setStartPositionEndpublic static WritableBuffer wrap(ByteBuffer byteBuf)
byteBuf - the given ByteBuffer, must not be null.public static WritableBuffer 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 WritableBuffer writableDuplicate()
public abstract WritableBuffer writableDuplicate(ByteOrder byteOrder)
byteOrder - the given ByteOrder.public abstract WritableBuffer writableRegion()
public abstract WritableBuffer writableRegion(long offsetBytes, long capacityBytes, ByteOrder byteOrder)
Note: asWritableMemory() and asMemory() will return 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 WritableMemory asWritableMemory()
public abstract void putBoolean(boolean value)
value - the value to putpublic abstract void putBoolean(long offsetBytes,
boolean value)
offsetBytes - offset bytes relative to this WritableMemory start.value - the value to putpublic abstract void putBooleanArray(boolean[] srcArray,
int srcOffsetBooleans,
int lengthBooleans)
srcArray - The source array.srcOffsetBooleans - offset in array unitslengthBooleans - number of array units to transferpublic abstract void putByte(byte value)
value - the value to putpublic abstract void putByte(long offsetBytes,
byte value)
offsetBytes - offset bytes relative to this WritableMemory startvalue - the value to putpublic abstract void putByteArray(byte[] srcArray,
int srcOffsetBytes,
int lengthBytes)
srcArray - The source array.srcOffsetBytes - offset in array unitslengthBytes - number of array units to transferpublic abstract void putChar(char value)
value - the value to putpublic abstract void putChar(long offsetBytes,
char value)
offsetBytes - offset bytes relative to this WritableMemory startvalue - the value to putpublic abstract void putCharArray(char[] srcArray,
int srcOffsetChars,
int lengthChars)
srcArray - The source array.srcOffsetChars - offset in array unitslengthChars - number of array units to transferpublic abstract void putDouble(double value)
value - the value to putpublic abstract void putDouble(long offsetBytes,
double value)
offsetBytes - offset bytes relative to this WritableMemory startvalue - the value to putpublic abstract void putDoubleArray(double[] srcArray,
int srcOffsetDoubles,
int lengthDoubles)
srcArray - The source array.srcOffsetDoubles - offset in array unitslengthDoubles - number of array units to transferpublic abstract void putFloat(float value)
value - the value to putpublic abstract void putFloat(long offsetBytes,
float value)
offsetBytes - offset bytes relative to this WritableMemory startvalue - the value to putpublic abstract void putFloatArray(float[] srcArray,
int srcOffsetFloats,
int lengthFloats)
srcArray - The source array.srcOffsetFloats - offset in array unitslengthFloats - number of array units to transferpublic abstract void putInt(int value)
value - the value to putpublic abstract void putInt(long offsetBytes,
int value)
offsetBytes - offset bytes relative to this WritableMemory startvalue - the value to putpublic abstract void putIntArray(int[] srcArray,
int srcOffsetInts,
int lengthInts)
srcArray - The source array.srcOffsetInts - offset in array unitslengthInts - number of array units to transferpublic abstract void putLong(long value)
value - the value to putpublic abstract void putLong(long offsetBytes,
long value)
offsetBytes - offset bytes relative to this WritableMemory startvalue - the value to putpublic abstract void putLongArray(long[] srcArray,
int srcOffsetLongs,
int lengthLongs)
srcArray - The source array.srcOffsetLongs - offset in array unitslengthLongs - number of array units to transferpublic abstract void putShort(short value)
value - the value to putpublic abstract void putShort(long offsetBytes,
short value)
offsetBytes - offset bytes relative to this WritableMemory startvalue - the value to putpublic abstract void putShortArray(short[] srcArray,
int srcOffsetShorts,
int lengthShorts)
srcArray - The source array.srcOffsetShorts - offset in array unitslengthShorts - number of array units to transferpublic abstract Object getArray()
public abstract void clear()
public abstract void fill(byte value)
value - the given byte valuepublic MemoryRequestServer getMemoryRequestServer()
WritableMemory.allocateDirect(long, MemoryRequestServer).
If not explicity set, this returns the DefaultMemoryRequestServer.public 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–2019 Yahoo! Inc.. All rights reserved.