java.lang.Object
org.lmdbjava.BufferProxy<io.netty.buffer.ByteBuf>
org.lmdbjava.ByteBufProxy
A buffer proxy backed by Netty's
ByteBuf.
This class requires UnsafeAccess and netty-buffer must be in the
classpath.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BufferProxy<io.netty.buffer.ByteBuf>A proxy for using NettyByteBuf.Fields inherited from class org.lmdbjava.BufferProxy
MDB_VAL_STRUCT_SIZE, STRUCT_FIELD_OFFSET_DATA, STRUCT_FIELD_OFFSET_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.netty.buffer.ByteBufallocate()Allocate a new buffer suitable for passing toBufferProxy.out(java.lang.Object, jnr.ffi.Pointer, long).intcompare(io.netty.buffer.ByteBuf o1, io.netty.buffer.ByteBuf o2) Compare the two buffers.voiddeallocate(io.netty.buffer.ByteBuf buff) Deallocate a buffer that was previously provided byBufferProxy.allocate().protected byte[]getBytes(io.netty.buffer.ByteBuf buffer) Obtain a copy of the bytes contained within the passed buffer.protected voidin(io.netty.buffer.ByteBuf buffer, int size, jnr.ffi.Pointer ptr, long ptrAddr) Called when theMDB_valshould be set to reflect the passed buffer.voidin(io.netty.buffer.ByteBuf buffer, jnr.ffi.Pointer ptr, long ptrAddr) Called when theMDB_valshould be set to reflect the passed buffer.io.netty.buffer.ByteBufout(io.netty.buffer.ByteBuf buffer, jnr.ffi.Pointer ptr, long ptrAddr) Called when theMDB_valmay have changed and the passed buffer should be modified to reflect the newMDB_val.
-
Field Details
-
PROXY_NETTY
A proxy for using NettyByteBuf. 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:BufferProxyAllocate a new buffer suitable for passing toBufferProxy.out(java.lang.Object, jnr.ffi.Pointer, long).- Specified by:
allocatein classBufferProxy<io.netty.buffer.ByteBuf>- Returns:
- a buffer for passing to the
outmethod
-
compare
public int compare(io.netty.buffer.ByteBuf o1, io.netty.buffer.ByteBuf o2) Description copied from class:BufferProxyCompare 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:
comparein classBufferProxy<io.netty.buffer.ByteBuf>- Parameters:
o1- left operando2- right operand- Returns:
- as per
Comparable
-
deallocate
public void deallocate(io.netty.buffer.ByteBuf buff) Description copied from class:BufferProxyDeallocate a buffer that was previously provided byBufferProxy.allocate().- Specified by:
deallocatein classBufferProxy<io.netty.buffer.ByteBuf>- Parameters:
buff- the buffer to deallocate (required)
-
getBytes
protected byte[] getBytes(io.netty.buffer.ByteBuf buffer) Description copied from class:BufferProxyObtain a copy of the bytes contained within the passed buffer.- Specified by:
getBytesin classBufferProxy<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:BufferProxyCalled when theMDB_valshould be set to reflect the passed buffer. This buffer will have been created by end users, notBufferProxy.allocate().- Specified by:
inin classBufferProxy<io.netty.buffer.ByteBuf>- Parameters:
buffer- the buffer to write toMDB_valptr- the pointer to theMDB_valptrAddr- the address of theMDB_valpointer
-
in
protected void in(io.netty.buffer.ByteBuf buffer, int size, jnr.ffi.Pointer ptr, long ptrAddr) Description copied from class:BufferProxyCalled when theMDB_valshould be set to reflect the passed buffer.- Specified by:
inin classBufferProxy<io.netty.buffer.ByteBuf>- Parameters:
buffer- the buffer to write toMDB_valsize- the buffer size to write toMDB_valptr- the pointer to theMDB_valptrAddr- the address of theMDB_valpointer
-
out
public io.netty.buffer.ByteBuf out(io.netty.buffer.ByteBuf buffer, jnr.ffi.Pointer ptr, long ptrAddr) Description copied from class:BufferProxyCalled when theMDB_valmay have changed and the passed buffer should be modified to reflect the newMDB_val.- Specified by:
outin classBufferProxy<io.netty.buffer.ByteBuf>- Parameters:
buffer- the buffer to write toMDB_valptr- the pointer to theMDB_valptrAddr- the address of theMDB_valpointer- Returns:
- the buffer for
MDB_val
-