Package org.apache.arrow.memory.util
Class MemoryUtil
- java.lang.Object
-
- org.apache.arrow.memory.util.MemoryUtil
-
public class MemoryUtil extends Object
Utilities for memory related operations.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanLITTLE_ENDIANIf the native byte order is little-endian.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longallocateMemory(long bytes)static voidcopyFromMemory(long srcAddress, byte[] dest, long destIndex, long bytes)static voidcopyMemory(long srcAddress, long destAddress, long bytes)static voidcopyToMemory(byte[] src, long srcIndex, long destAddress, long bytes)static ByteBufferdirectBuffer(long address, int capacity)Create nio byte buffer.static voidfreeMemory(long address)static bytegetByte(long address)static longgetByteBufferAddress(ByteBuffer buf)Given aByteBuffer, gets the address the underlying memory space.static intgetInt(byte[] bytes, int index)static intgetInt(long address)static longgetLong(byte[] bytes, int index)static longgetLong(long address)static shortgetShort(long address)static voidputByte(long address, byte value)static voidputInt(long address, int value)static voidputLong(long address, long value)static voidputShort(long address, short value)static voidsetMemory(long address, long bytes, byte value)
-
-
-
Method Detail
-
getByteBufferAddress
public static long getByteBufferAddress(ByteBuffer buf)
Given aByteBuffer, gets the address the underlying memory space.- Parameters:
buf- the byte buffer.- Returns:
- address of the underlying memory.
-
directBuffer
public static ByteBuffer directBuffer(long address, int capacity)
Create nio byte buffer.
-
copyMemory
public static void copyMemory(long srcAddress, long destAddress, long bytes)
-
copyToMemory
public static void copyToMemory(byte[] src, long srcIndex, long destAddress, long bytes)
-
copyFromMemory
public static void copyFromMemory(long srcAddress, byte[] dest, long destIndex, long bytes)
-
getByte
public static byte getByte(long address)
-
putByte
public static void putByte(long address, byte value)
-
getShort
public static short getShort(long address)
-
putShort
public static void putShort(long address, short value)
-
getInt
public static int getInt(long address)
-
putInt
public static void putInt(long address, int value)
-
getLong
public static long getLong(long address)
-
putLong
public static void putLong(long address, long value)
-
setMemory
public static void setMemory(long address, long bytes, byte value)
-
getInt
public static int getInt(byte[] bytes, int index)
-
getLong
public static long getLong(byte[] bytes, int index)
-
allocateMemory
public static long allocateMemory(long bytes)
-
freeMemory
public static void freeMemory(long address)
-
-