Class AlignedBuffers


  • public class AlignedBuffers
    extends Object
    Utility class for work with aligned buffers.
    • Constructor Detail

      • AlignedBuffers

        public AlignedBuffers()
    • Method Detail

      • allocate

        public static ByteBuffer allocate​(int fsBlockSize,
                                          int size)
        Allocates align memory for use with O_DIRECT and returns native byte buffer.
        Parameters:
        fsBlockSize - alignment, FS ans OS block size.
        size - capacity.
        Returns:
        byte buffer, to be released by free(ByteBuffer).
      • free

        public static void free​(ByteBuffer buf)
        Frees the memory space used by direct buffer, which must have been returned by a previous call allocate(int, int).
        Parameters:
        buf - direct buffer to free.
      • free

        public static void free​(long addr)
        Frees the memory space pointed to by addr - address of buffer, which must have been returned by a previous call allocate(int, int).
        Parameters:
        addr - direct buffer address to free.