public abstract class BaseBuffer extends Object
0 <= start <= position <= end <= capacity.setStartPositionEnd(long, long, long)| Modifier and Type | Method and Description |
|---|---|
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. |
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.
|
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.
|
long |
getEnd()
Gets the end position
|
long |
getPosition()
Gets 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.
|
long |
getRemaining()
The number of elements remaining between the current position and the end position
|
long |
getStart()
Gets start 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 |
hasRemaining()
Returns true if there are elements remaining between the current position and the end position
|
BaseBuffer |
incrementAndCheckPosition(long increment)
Increments the current position by the given increment.
|
BaseBuffer |
incrementPosition(long increment)
Increments the current position by the given increment.
|
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.
|
BaseBuffer |
resetPosition()
Resets the current position to the start position,
This does not modify any data.
|
BaseBuffer |
setAndCheckPosition(long position)
Sets the current position.
|
BaseBuffer |
setAndCheckStartPositionEnd(long start,
long position,
long end)
Sets start position, current position, and end position.
|
BaseBuffer |
setPosition(long position)
Sets the current position.
|
BaseBuffer |
setStartPositionEnd(long start,
long position,
long end)
Sets start position, current position, and end position.
|
String |
toHexString(String header,
long offsetBytes,
int lengthBytes)
Returns a formatted hex string of a range 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.
|
public final BaseBuffer incrementPosition(long increment)
AssertionError.increment - the given incrementpublic final BaseBuffer incrementAndCheckPosition(long increment)
IllegalArgumentException.increment - the given incrementpublic final long getEnd()
public final long getPosition()
public final long getStart()
public final long getRemaining()
(end - position)public final boolean hasRemaining()
(end - position) > 0public final BaseBuffer resetPosition()
public final BaseBuffer setPosition(long position)
AssertionError.position - the given current position.public final BaseBuffer setAndCheckPosition(long position)
IllegalArgumentException.position - the given current position.public final BaseBuffer setStartPositionEnd(long start, long position, long end)
AssertionError.start - the start position in the bufferposition - the current position between the start and endend - the end position in the bufferpublic final BaseBuffer setAndCheckStartPositionEnd(long start, long position, long end)
IllegalArgumentException.start - the start position in the bufferposition - the current position between the start and endend - the end position in the 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–2019 Yahoo! Inc.. All rights reserved.