@InterfaceAudience.Private @InterfaceStability.Evolving public final class UnsafeAccess extends Object
Modifier and Type | Field and Description |
---|---|
static long |
BYTE_ARRAY_BASE_OFFSET
The offset to the first element in a byte array.
|
static boolean |
LITTLE_ENDIAN |
(package private) static long |
UNSAFE_COPY_THRESHOLD |
Modifier | Constructor and Description |
---|---|
private |
UnsafeAccess() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(byte[] src,
int srcOffset,
ByteBuffer dest,
int destOffset,
int length)
Copies the bytes from given array's offset to length part into the given buffer.
|
static void |
copy(ByteBuffer src,
int srcOffset,
byte[] dest,
int destOffset,
int length)
Copies specified number of bytes from given offset of
src ByteBuffer to the
dest array. |
static void |
copy(ByteBuffer src,
int srcOffset,
ByteBuffer dest,
int destOffset,
int length)
Copies specified number of bytes from given offset of
src buffer into the dest
buffer. |
static long |
directBufferAddress(ByteBuffer buf) |
static void |
freeDirectBuffer(ByteBuffer buffer) |
private static int |
getAsInt(ByteBuffer buf,
int offset)
Reads bytes at the given offset as an int value.
|
private static long |
getAsLong(ByteBuffer buf,
int offset)
Reads bytes at the given offset as a long value.
|
private static short |
getAsShort(ByteBuffer buf,
int offset)
Reads bytes at the given offset as a short value.
|
static int |
putByte(ByteBuffer buf,
int offset,
byte b)
Put a byte value out to the specified BB position in big-endian format.
|
static int |
putInt(byte[] bytes,
int offset,
int val)
Put an int value out to the specified byte array position in big-endian format.
|
static int |
putInt(ByteBuffer buf,
int offset,
int val)
Put an int value out to the specified ByteBuffer offset in big-endian format.
|
static int |
putLong(byte[] bytes,
int offset,
long val)
Put a long value out to the specified byte array position in big-endian format.
|
static int |
putLong(ByteBuffer buf,
int offset,
long val)
Put a long value out to the specified BB position in big-endian format.
|
static int |
putShort(byte[] bytes,
int offset,
short val)
Put a short value out to the specified byte array position in big-endian format.
|
static int |
putShort(ByteBuffer buf,
int offset,
short val)
Put a short value out to the specified BB position in big-endian format.
|
static byte |
toByte(ByteBuffer buf,
int offset)
Returns the byte at the given offset
|
static byte |
toByte(Object ref,
long offset)
Returns the byte at the given offset of the object
|
static int |
toInt(byte[] bytes,
int offset)
Converts a byte array to an int value considering it was written in big-endian format.
|
static int |
toInt(ByteBuffer buf,
int offset)
Reads an int value at the given buffer's offset considering it was written in big-endian
format.
|
static int |
toInt(Object ref,
long offset)
Reads a int value at the given Object's offset considering it was written in big-endian format.
|
static long |
toLong(byte[] bytes,
int offset)
Converts a byte array to a long value considering it was written in big-endian format.
|
static long |
toLong(ByteBuffer buf,
int offset)
Reads a long value at the given buffer's offset considering it was written in big-endian
format.
|
static long |
toLong(Object ref,
long offset)
Reads a long value at the given Object's offset considering it was written in big-endian
format.
|
static short |
toShort(byte[] bytes,
int offset)
Converts a byte array to a short value considering it was written in big-endian format.
|
static short |
toShort(ByteBuffer buf,
int offset)
Reads a short value at the given buffer's offset considering it was written in big-endian
format.
|
static short |
toShort(Object ref,
long offset)
Reads a short value at the given Object's offset considering it was written in big-endian
format.
|
private static void |
unsafeCopy(Object src,
long srcAddr,
Object dst,
long destAddr,
long len) |
public static final long BYTE_ARRAY_BASE_OFFSET
public static final boolean LITTLE_ENDIAN
static final long UNSAFE_COPY_THRESHOLD
private UnsafeAccess()
public static short toShort(byte[] bytes, int offset)
bytes
- byte arrayoffset
- offset into arraypublic static int toInt(byte[] bytes, int offset)
bytes
- byte arrayoffset
- offset into arraypublic static long toLong(byte[] bytes, int offset)
bytes
- byte arrayoffset
- offset into arraypublic static int putShort(byte[] bytes, int offset, short val)
bytes
- the byte arrayoffset
- position in the arrayval
- short to write outpublic static int putInt(byte[] bytes, int offset, int val)
bytes
- the byte arrayoffset
- position in the arrayval
- int to write outpublic static int putLong(byte[] bytes, int offset, long val)
bytes
- the byte arrayoffset
- position in the arrayval
- long to write outpublic static short toShort(ByteBuffer buf, int offset)
public static short toShort(Object ref, long offset)
private static short getAsShort(ByteBuffer buf, int offset)
public static int toInt(ByteBuffer buf, int offset)
public static int toInt(Object ref, long offset)
private static int getAsInt(ByteBuffer buf, int offset)
public static long toLong(ByteBuffer buf, int offset)
public static long toLong(Object ref, long offset)
private static long getAsLong(ByteBuffer buf, int offset)
public static byte toByte(ByteBuffer buf, int offset)
buf
- the buffer to readoffset
- the offset at which the byte has to be readpublic static byte toByte(Object ref, long offset)
public static int putInt(ByteBuffer buf, int offset, int val)
buf
- the ByteBuffer to write tooffset
- offset in the ByteBufferval
- int to write outpublic static void copy(byte[] src, int srcOffset, ByteBuffer dest, int destOffset, int length)
src
- source arraysrcOffset
- offset into source bufferdest
- destination bufferdestOffset
- offset into destination bufferlength
- length of data to copyprivate static void unsafeCopy(Object src, long srcAddr, Object dst, long destAddr, long len)
public static void copy(ByteBuffer src, int srcOffset, byte[] dest, int destOffset, int length)
src
ByteBuffer to the
dest
array.src
- source buffersrcOffset
- offset into source bufferdest
- destination arraydestOffset
- offset into destination bufferlength
- length of data to copypublic static void copy(ByteBuffer src, int srcOffset, ByteBuffer dest, int destOffset, int length)
src
buffer into the dest
buffer.src
- source buffersrcOffset
- offset into source bufferdest
- destination bufferdestOffset
- offset into destination bufferlength
- length of data to copypublic static int putShort(ByteBuffer buf, int offset, short val)
buf
- the byte bufferoffset
- position in the bufferval
- short to write outpublic static int putLong(ByteBuffer buf, int offset, long val)
buf
- the byte bufferoffset
- position in the bufferval
- long to write outpublic static int putByte(ByteBuffer buf, int offset, byte b)
buf
- the byte bufferoffset
- position in the bufferb
- byte to write outpublic static long directBufferAddress(ByteBuffer buf)
public static void freeDirectBuffer(ByteBuffer buffer)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.