Class MemoryUtil

java.lang.Object
org.apache.cassandra.utils.memory.MemoryUtil
Direct Known Subclasses:
LittleEndianMemoryUtil, NativeEndianMemoryUtil

public abstract class MemoryUtil extends Object
  • Field Details

    • unsafe

      protected static final sun.misc.Unsafe unsafe
    • BYTE_BUFFER_CLASS

      protected static final Class<?> BYTE_BUFFER_CLASS
  • Constructor Details

    • MemoryUtil

      public MemoryUtil()
  • Method Details

    • pageSize

      public static int pageSize()
    • getAddress

      public static long getAddress(ByteBuffer buffer)
    • allocate

      public static long allocate(long size)
    • free

      public static void free(long peer)
    • setByte

      public static void setByte(long address, byte b)
    • setByte

      public static void setByte(long address, int count, byte b)
    • getByte

      public static byte getByte(long address)
    • getByteBuffer

      public static ByteBuffer getByteBuffer(long address, int length)
    • getByteBuffer

      public static ByteBuffer getByteBuffer(long address, int length, ByteOrder order)
    • getHollowDirectByteBuffer

      public static ByteBuffer getHollowDirectByteBuffer()
    • getHollowDirectByteBuffer

      public static ByteBuffer getHollowDirectByteBuffer(ByteOrder order)
    • isExactlyDirect

      public static boolean isExactlyDirect(ByteBuffer buffer)
    • getAttachment

      public static Object getAttachment(ByteBuffer instance)
    • setAttachment

      public static void setAttachment(ByteBuffer instance, Object next)
    • duplicateDirectByteBuffer

      public static ByteBuffer duplicateDirectByteBuffer(ByteBuffer source, ByteBuffer hollowBuffer)
    • sliceDirectByteBuffer

      public static ByteBuffer sliceDirectByteBuffer(ByteBuffer source, ByteBuffer hollowBuffer, int offset, int length)
    • setDirectByteBuffer

      public static void setDirectByteBuffer(ByteBuffer instance, long address, int length)
    • setByteBufferCapacity

      public static void setByteBufferCapacity(ByteBuffer instance, int capacity)
    • setBytes

      public static void setBytes(long address, ByteBuffer buffer)
    • setBytes

      public static void setBytes(long address, byte[] buffer, int bufferOffset, int count)
      Transfers count bytes from buffer to Memory
      Parameters:
      address - start offset in the memory
      buffer - the data buffer
      bufferOffset - start offset of the buffer
      count - number of bytes to transfer
    • setBytes

      public static void setBytes(long src, long trg, long count)
    • setBytes

      public static void setBytes(byte[] src, int offset, long trg, long count)
    • getBytes

      public static void getBytes(long address, byte[] buffer, int bufferOffset, int count)
      Transfers count bytes from Memory starting at memoryOffset to buffer starting at bufferOffset
      Parameters:
      address - start offset in the memory
      buffer - the data buffer
      bufferOffset - start offset of the buffer
      count - number of bytes to transfer