public interface Memory extends BaseState
defaultMemReqSvr| Modifier and Type | Method and Description |
|---|---|
default Buffer |
asBuffer()
Returns a new Buffer view of this object.
|
Buffer |
asBuffer(ByteOrder byteOrder)
Returns a new Buffer view of this object, with the given
byte order.
|
int |
compareTo(long thisOffsetBytes,
long thisLengthBytes,
Memory that,
long thatOffsetBytes,
long thatLengthBytes)
Compares the bytes of this Memory to that Memory.
|
void |
copyTo(long srcOffsetBytes,
WritableMemory destination,
long dstOffsetBytes,
long lengthBytes)
Copies bytes from a source range of this Memory to a destination range of the given Memory
with the same semantics when copying between overlapping ranges of bytes as method
System.arraycopy(Object, int, Object, int, int) has. |
boolean |
getBoolean(long offsetBytes)
Gets the boolean value at the given offset
|
void |
getBooleanArray(long offsetBytes,
boolean[] dstArray,
int dstOffsetBooleans,
int lengthBooleans)
Gets the boolean array at the given offset
|
byte |
getByte(long offsetBytes)
Gets the byte value at the given offset
|
void |
getByteArray(long offsetBytes,
byte[] dstArray,
int dstOffsetBytes,
int lengthBytes)
Gets the byte array at the given offset
|
char |
getChar(long offsetBytes)
Gets the char value at the given offset
|
void |
getCharArray(long offsetBytes,
char[] dstArray,
int dstOffsetChars,
int lengthChars)
Gets the char array at the given offset
|
int |
getCharsFromUtf8(long offsetBytes,
int utf8LengthBytes,
Appendable dst)
Gets UTF-8 encoded bytes from this Memory, starting at offsetBytes to a length of
utf8LengthBytes, decodes them into characters and appends them to the given Appendable.
|
int |
getCharsFromUtf8(long offsetBytes,
int utf8LengthBytes,
StringBuilder dst)
Gets UTF-8 encoded bytes from this Memory, starting at offsetBytes to a length of
utf8LengthBytes, decodes them into characters and appends them to the given StringBuilder.
|
double |
getDouble(long offsetBytes)
Gets the double value at the given offset
|
void |
getDoubleArray(long offsetBytes,
double[] dstArray,
int dstOffsetDoubles,
int lengthDoubles)
Gets the double array at the given offset
|
float |
getFloat(long offsetBytes)
Gets the float value at the given offset
|
void |
getFloatArray(long offsetBytes,
float[] dstArray,
int dstOffsetFloats,
int lengthFloats)
Gets the float array at the given offset
|
int |
getInt(long offsetBytes)
Gets the int value at the given offset
|
void |
getIntArray(long offsetBytes,
int[] dstArray,
int dstOffsetInts,
int lengthInts)
Gets the int array at the given offset
|
long |
getLong(long offsetBytes)
Gets the long value at the given offset
|
void |
getLongArray(long offsetBytes,
long[] dstArray,
int dstOffsetLongs,
int lengthLongs)
Gets the long array at the given offset
|
short |
getShort(long offsetBytes)
Gets the short value at the given offset
|
void |
getShortArray(long offsetBytes,
short[] dstArray,
int dstOffsetShorts,
int lengthShorts)
Gets the short array at the given offset
|
static MapHandle |
map(File file)
Maps the entire given file into native-ordered Memory for read operations
Calling this method is equivalent to calling
map(file, 0, file.length(), ByteOrder.nativeOrder()). |
static MapHandle |
map(File file,
long fileOffsetBytes,
long capacityBytes,
ByteOrder byteOrder)
Maps the specified portion of the given file into Memory for read operations.
|
default Memory |
region(long offsetBytes,
long capacityBytes)
A region is a read-only view of this object.
|
Memory |
region(long offsetBytes,
long capacityBytes,
ByteOrder byteOrder)
A region is a read-only view of this object.
|
static Memory |
wrap(boolean[] array)
Wraps the given primitive array for read operations assuming native byte order.
|
static Memory |
wrap(byte[] array)
Wraps the given primitive array for read operations assuming native byte order.
|
static Memory |
wrap(byte[] array,
ByteOrder byteOrder)
Wraps the given primitive array for read operations with the given byte order.
|
static Memory |
wrap(byte[] array,
int offsetBytes,
int lengthBytes,
ByteOrder byteOrder)
Wraps the given primitive array for read operations with the given byte order.
|
static Memory |
wrap(ByteBuffer byteBuffer)
Accesses the given ByteBuffer for read-only operations.
|
static Memory |
wrap(ByteBuffer byteBuffer,
ByteOrder byteOrder)
Accesses the given ByteBuffer for read-only operations.
|
static Memory |
wrap(char[] array)
Wraps the given primitive array for read operations assuming native byte order.
|
static Memory |
wrap(double[] array)
Wraps the given primitive array for read operations assuming native byte order.
|
static Memory |
wrap(float[] array)
Wraps the given primitive array for read operations assuming native byte order.
|
static Memory |
wrap(int[] array)
Wraps the given primitive array for read operations assuming native byte order.
|
static Memory |
wrap(long[] array)
Wraps the given primitive array for read operations assuming native byte order.
|
static Memory |
wrap(short[] array)
Wraps the given primitive array for read operations assuming native byte order.
|
void |
writeTo(long offsetBytes,
long lengthBytes,
WritableByteChannel out)
Writes bytes from a source range of this Memory to the given
WritableByteChannel. |
checkValidAndBounds, equals, equalTo, getByteBuffer, getCapacity, getCumulativeOffset, getCumulativeOffset, getCurrentDirectMemoryAllocated, getCurrentDirectMemoryAllocations, getCurrentDirectMemoryMapAllocated, getCurrentDirectMemoryMapAllocations, getRegionOffset, getRegionOffset, getTypeByteOrder, hasArray, hasByteBuffer, hashCode, isByteOrderCompatible, isDirect, isReadOnly, isSameResource, isValid, toHexString, xxHash64, xxHash64static Memory wrap(ByteBuffer byteBuffer)
byteBuffer - the given ByteBuffer. It must be non-null and with capacity ≥ 0.static Memory wrap(ByteBuffer byteBuffer, ByteOrder byteOrder)
byteBuffer - the given ByteBuffer. It must be non-null and with capacity ≥ 0.byteOrder - the byte order to be used. It must be non-null.static MapHandle map(File file)
map(file, 0, file.length(), ByteOrder.nativeOrder()).file - the given file to map. It must be non-null, length ≥ 0, and readable.Handle.static MapHandle map(File file, long fileOffsetBytes, long capacityBytes, ByteOrder byteOrder)
file - the given file to map. It must be non-null and readable.fileOffsetBytes - the position in the given file in bytes. It must not be negative.capacityBytes - the size of the mapped memory. It must not be negative.byteOrder - the byte order to be used for the mapped memory. It must be non-null.Handle.default Memory region(long offsetBytes, long capacityBytes)
offsetBytes - the starting offset with respect to the origin of this Memory. It must be ≥ 0.capacityBytes - the capacity of the region in bytes. It must be ≥ 0.Memory region(long offsetBytes, long capacityBytes, ByteOrder byteOrder)
offsetBytes - the starting offset with respect to the origin of this Memory. It must be ≥ 0.capacityBytes - the capacity of the region in bytes. It must be ≥ 0.byteOrder - the given byte order. It must be non-null.default Buffer asBuffer()
Buffer asBuffer(ByteOrder byteOrder)
byteOrder - the given byte orderstatic Memory wrap(byte[] array)
array - the given primitive array.static Memory wrap(byte[] array, ByteOrder byteOrder)
array - the given primitive array.byteOrder - the byte order to be usedstatic Memory wrap(byte[] array, int offsetBytes, int lengthBytes, ByteOrder byteOrder)
array - the given primitive array.offsetBytes - the byte offset into the given arraylengthBytes - the number of bytes to include from the given arraybyteOrder - the byte order to be usedstatic Memory wrap(boolean[] array)
array - the given primitive array.static Memory wrap(char[] array)
array - the given primitive array.static Memory wrap(short[] array)
array - the given primitive array.static Memory wrap(int[] array)
array - the given primitive array.static Memory wrap(long[] array)
array - the given primitive array.static Memory wrap(float[] array)
array - the given primitive array.static Memory wrap(double[] array)
array - the given primitive array.boolean getBoolean(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startvoid getBooleanArray(long offsetBytes,
boolean[] dstArray,
int dstOffsetBooleans,
int lengthBooleans)
offsetBytes - offset bytes relative to this Memory startdstArray - The preallocated destination array.dstOffsetBooleans - offset in array unitslengthBooleans - number of array units to transferbyte getByte(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startvoid getByteArray(long offsetBytes,
byte[] dstArray,
int dstOffsetBytes,
int lengthBytes)
offsetBytes - offset bytes relative to this Memory startdstArray - The preallocated destination array.dstOffsetBytes - offset in array unitslengthBytes - number of array units to transferchar getChar(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startvoid getCharArray(long offsetBytes,
char[] dstArray,
int dstOffsetChars,
int lengthChars)
offsetBytes - offset bytes relative to this Memory startdstArray - The preallocated destination array.dstOffsetChars - offset in array unitslengthChars - number of array units to transferint getCharsFromUtf8(long offsetBytes,
int utf8LengthBytes,
Appendable dst)
throws IOException,
Utf8CodingException
offsetBytes - offset bytes relative to the Memory startutf8LengthBytes - the number of encoded UTF-8 bytes to decode. It is assumed that the
caller has the correct number of utf8 bytes required to decode the number of characters
to be appended to dst. Characters outside the ASCII range can require 2, 3 or 4 bytes per
character to decode.dst - the destination Appendable to append the decoded characters to.IOException - if dst.append() throws IOExceptionUtf8CodingException - in case of malformed or illegal UTF-8 inputint getCharsFromUtf8(long offsetBytes,
int utf8LengthBytes,
StringBuilder dst)
throws Utf8CodingException
offsetBytes - offset bytes relative to the Memory startutf8LengthBytes - the number of encoded UTF-8 bytes to decode. It is assumed that the
caller has the correct number of utf8 bytes required to decode the number of characters
to be appended to dst. Characters outside the ASCII range can require 2, 3 or 4 bytes per
character to decode.dst - the destination StringBuilder to append decoded characters to.Utf8CodingException - in case of malformed or illegal UTF-8 inputdouble getDouble(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startvoid getDoubleArray(long offsetBytes,
double[] dstArray,
int dstOffsetDoubles,
int lengthDoubles)
offsetBytes - offset bytes relative to this Memory startdstArray - The preallocated destination array.dstOffsetDoubles - offset in array unitslengthDoubles - number of array units to transferfloat getFloat(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startvoid getFloatArray(long offsetBytes,
float[] dstArray,
int dstOffsetFloats,
int lengthFloats)
offsetBytes - offset bytes relative to this Memory startdstArray - The preallocated destination array.dstOffsetFloats - offset in array unitslengthFloats - number of array units to transferint getInt(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startvoid getIntArray(long offsetBytes,
int[] dstArray,
int dstOffsetInts,
int lengthInts)
offsetBytes - offset bytes relative to this Memory startdstArray - The preallocated destination array.dstOffsetInts - offset in array unitslengthInts - number of array units to transferlong getLong(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startvoid getLongArray(long offsetBytes,
long[] dstArray,
int dstOffsetLongs,
int lengthLongs)
offsetBytes - offset bytes relative to this Memory startdstArray - The preallocated destination array.dstOffsetLongs - offset in array unitslengthLongs - number of array units to transfershort getShort(long offsetBytes)
offsetBytes - offset bytes relative to this Memory startvoid getShortArray(long offsetBytes,
short[] dstArray,
int dstOffsetShorts,
int lengthShorts)
offsetBytes - offset bytes relative to this Memory startdstArray - The preallocated destination array.dstOffsetShorts - offset in array unitslengthShorts - number of array units to transferint compareTo(long thisOffsetBytes,
long thisLengthBytes,
Memory that,
long thatOffsetBytes,
long thatLengthBytes)
thisOffsetBytes - the starting offset for this MemorythisLengthBytes - the length of the region to compare from this Memorythat - the other Memory to compare withthatOffsetBytes - the starting offset for that MemorythatLengthBytes - the length of the region to compare from that Memoryvoid copyTo(long srcOffsetBytes,
WritableMemory destination,
long dstOffsetBytes,
long lengthBytes)
System.arraycopy(Object, int, Object, int, int) has. However, if the source
and the destination ranges are exactly the same, this method throws IllegalArgumentException, because it should never be needed in real-world scenarios and
therefore indicates a bug.srcOffsetBytes - the source offset for this Memorydestination - the destination Memory, which may not be Read-Only.dstOffsetBytes - the destination offsetlengthBytes - the number of bytes to copyvoid writeTo(long offsetBytes,
long lengthBytes,
WritableByteChannel out)
throws IOException
WritableByteChannel.offsetBytes - the source offset for this MemorylengthBytes - the number of bytes to copyout - the destination WritableByteChannelIOException - may occur while writing to the WritableByteChannelCopyright © 2015–2020 The Apache Software Foundation. All rights reserved.