Module lmdbjava
Package org.lmdbjava

Class DirectBufferProxy

java.lang.Object
org.lmdbjava.BufferProxy<org.agrona.DirectBuffer>
org.lmdbjava.DirectBufferProxy

public final class DirectBufferProxy extends BufferProxy<org.agrona.DirectBuffer>
A buffer proxy backed by Agrona's DirectBuffer.

This class requires UnsafeAccess and Agrona must be in the classpath.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BufferProxy<org.agrona.DirectBuffer>
    The MutableDirectBuffer proxy.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.agrona.DirectBuffer
    Allocate a new buffer suitable for passing to BufferProxy.out(java.lang.Object, jnr.ffi.Pointer, long).
    int
    compare(org.agrona.DirectBuffer o1, org.agrona.DirectBuffer o2)
    Compare the two buffers.
    static int
    compareBuff(org.agrona.DirectBuffer o1, org.agrona.DirectBuffer o2)
    Lexicographically compare two buffers.
    void
    deallocate(org.agrona.DirectBuffer buff)
    Deallocate a buffer that was previously provided by BufferProxy.allocate().
    protected byte[]
    getBytes(org.agrona.DirectBuffer buffer)
    Obtain a copy of the bytes contained within the passed buffer.
    protected void
    in(org.agrona.DirectBuffer buffer, int size, jnr.ffi.Pointer ptr, long ptrAddr)
    Called when the MDB_val should be set to reflect the passed buffer.
    void
    in(org.agrona.DirectBuffer buffer, jnr.ffi.Pointer ptr, long ptrAddr)
    Called when the MDB_val should be set to reflect the passed buffer.
    org.agrona.DirectBuffer
    out(org.agrona.DirectBuffer 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_DB

      public static final BufferProxy<org.agrona.DirectBuffer> PROXY_DB
      The MutableDirectBuffer proxy. Guaranteed to never be null, although a class initialization exception will occur if an attempt is made to access this field when unsafe or Agrona is unavailable.
  • Method Details

    • compareBuff

      public static int compareBuff(org.agrona.DirectBuffer o1, org.agrona.DirectBuffer o2)
      Lexicographically compare two buffers.
      Parameters:
      o1 - left operand (required)
      o2 - right operand (required)
      Returns:
      as specified by Comparable interface
    • allocate

      public org.agrona.DirectBuffer 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<org.agrona.DirectBuffer>
      Returns:
      a buffer for passing to the out method
    • compare

      public int compare(org.agrona.DirectBuffer o1, org.agrona.DirectBuffer 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<org.agrona.DirectBuffer>
      Parameters:
      o1 - left operand
      o2 - right operand
      Returns:
      as per Comparable
    • deallocate

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

      protected byte[] getBytes(org.agrona.DirectBuffer buffer)
      Description copied from class: BufferProxy
      Obtain a copy of the bytes contained within the passed buffer.
      Specified by:
      getBytes in class BufferProxy<org.agrona.DirectBuffer>
      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(org.agrona.DirectBuffer 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<org.agrona.DirectBuffer>
      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(org.agrona.DirectBuffer 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<org.agrona.DirectBuffer>
      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 org.agrona.DirectBuffer out(org.agrona.DirectBuffer 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<org.agrona.DirectBuffer>
      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