Module lmdbjava
Package org.lmdbjava

Class ByteBufProxy

java.lang.Object
org.lmdbjava.BufferProxy<io.netty.buffer.ByteBuf>
org.lmdbjava.ByteBufProxy

public final class ByteBufProxy extends BufferProxy<io.netty.buffer.ByteBuf>
A buffer proxy backed by Netty's ByteBuf.

This class requires UnsafeAccess and netty-buffer must be in the classpath.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BufferProxy<io.netty.buffer.ByteBuf>
    A proxy for using Netty ByteBuf.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ByteBufProxy(io.netty.buffer.PooledByteBufAllocator allocator)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    io.netty.buffer.ByteBuf
    Allocate a new buffer suitable for passing to BufferProxy.out(java.lang.Object, jnr.ffi.Pointer, long).
    int
    compare(io.netty.buffer.ByteBuf o1, io.netty.buffer.ByteBuf o2)
    Compare the two buffers.
    void
    deallocate(io.netty.buffer.ByteBuf buff)
    Deallocate a buffer that was previously provided by BufferProxy.allocate().
    protected byte[]
    getBytes(io.netty.buffer.ByteBuf buffer)
    Obtain a copy of the bytes contained within the passed buffer.
    protected void
    in(io.netty.buffer.ByteBuf buffer, int size, jnr.ffi.Pointer ptr, long ptrAddr)
    Called when the MDB_val should be set to reflect the passed buffer.
    void
    in(io.netty.buffer.ByteBuf buffer, jnr.ffi.Pointer ptr, long ptrAddr)
    Called when the MDB_val should be set to reflect the passed buffer.
    io.netty.buffer.ByteBuf
    out(io.netty.buffer.ByteBuf buffer, jnr.ffi.Pointer ptr, long ptrAddr)
    Called when the MDB_val may have changed and the passed buffer should be modified to reflect the new MDB_val.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PROXY_NETTY

      public static final BufferProxy<io.netty.buffer.ByteBuf> PROXY_NETTY
      A proxy for using Netty ByteBuf. Guaranteed to never be null, although a class initialization exception will occur if an attempt is made to access this field when Netty is unavailable.
  • Constructor Details

    • ByteBufProxy

      public ByteBufProxy(io.netty.buffer.PooledByteBufAllocator allocator)
  • Method Details

    • allocate

      public io.netty.buffer.ByteBuf allocate()
      Description copied from class: BufferProxy
      Allocate a new buffer suitable for passing to BufferProxy.out(java.lang.Object, jnr.ffi.Pointer, long).
      Specified by:
      allocate in class BufferProxy<io.netty.buffer.ByteBuf>
      Returns:
      a buffer for passing to the out method
    • compare

      public int compare(io.netty.buffer.ByteBuf o1, io.netty.buffer.ByteBuf o2)
      Description copied from class: BufferProxy
      Compare the two buffers.

      Implemented as a protected method to discourage use of the buffer proxy in collections etc (given by design it wraps a temporary value only).

      Specified by:
      compare in class BufferProxy<io.netty.buffer.ByteBuf>
      Parameters:
      o1 - left operand
      o2 - right operand
      Returns:
      as per Comparable
    • deallocate

      public void deallocate(io.netty.buffer.ByteBuf buff)
      Description copied from class: BufferProxy
      Deallocate a buffer that was previously provided by BufferProxy.allocate().
      Specified by:
      deallocate in class BufferProxy<io.netty.buffer.ByteBuf>
      Parameters:
      buff - the buffer to deallocate (required)
    • getBytes

      protected byte[] getBytes(io.netty.buffer.ByteBuf buffer)
      Description copied from class: BufferProxy
      Obtain a copy of the bytes contained within the passed buffer.
      Specified by:
      getBytes in class BufferProxy<io.netty.buffer.ByteBuf>
      Parameters:
      buffer - a non-null buffer created by this proxy instance
      Returns:
      a copy of the bytes this buffer is currently representing
    • in

      public void in(io.netty.buffer.ByteBuf buffer, jnr.ffi.Pointer ptr, long ptrAddr)
      Description copied from class: BufferProxy
      Called when the MDB_val should be set to reflect the passed buffer. This buffer will have been created by end users, not BufferProxy.allocate().
      Specified by:
      in in class BufferProxy<io.netty.buffer.ByteBuf>
      Parameters:
      buffer - the buffer to write to MDB_val
      ptr - the pointer to the MDB_val
      ptrAddr - the address of the MDB_val pointer
    • in

      protected void in(io.netty.buffer.ByteBuf buffer, int size, jnr.ffi.Pointer ptr, long ptrAddr)
      Description copied from class: BufferProxy
      Called when the MDB_val should be set to reflect the passed buffer.
      Specified by:
      in in class BufferProxy<io.netty.buffer.ByteBuf>
      Parameters:
      buffer - the buffer to write to MDB_val
      size - the buffer size to write to MDB_val
      ptr - the pointer to the MDB_val
      ptrAddr - the address of the MDB_val pointer
    • out

      public io.netty.buffer.ByteBuf out(io.netty.buffer.ByteBuf buffer, jnr.ffi.Pointer ptr, long ptrAddr)
      Description copied from class: BufferProxy
      Called when the MDB_val may have changed and the passed buffer should be modified to reflect the new MDB_val.
      Specified by:
      out in class BufferProxy<io.netty.buffer.ByteBuf>
      Parameters:
      buffer - the buffer to write to MDB_val
      ptr - the pointer to the MDB_val
      ptrAddr - the address of the MDB_val pointer
      Returns:
      the buffer for MDB_val