java.lang.Object
org.lmdbjava.BufferProxy<T>
- Type Parameters:
T- buffer type
- Direct Known Subclasses:
ByteArrayProxy,ByteBufferProxy.AbstractByteBufferProxy,ByteBufProxy,DirectBufferProxy
The strategy for mapping memory address to a given buffer type.
The proxy is passed to the Env.create(org.lmdbjava.BufferProxy)
method and is subsequently used by every Txn, Dbi and
Cursor associated with the Env.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSize of aMDB_valpointer in bytes.protected static final intOffset from a pointer of theMDB_val.mv_datafield.protected static final intOffset from a pointer of theMDB_val.mv_sizefield. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Tallocate()Allocate a new buffer suitable for passing toout(java.lang.Object, jnr.ffi.Pointer, long).abstract intCompare the two buffers.abstract voiddeallocate(T buff) Deallocate a buffer that was previously provided byallocate().protected abstract byte[]Obtain a copy of the bytes contained within the passed buffer.protected abstract voidCalled when theMDB_valshould be set to reflect the passed buffer.abstract voidCalled when theMDB_valshould be set to reflect the passed buffer.abstract TCalled when theMDB_valmay have changed and the passed buffer should be modified to reflect the newMDB_val.
-
Field Details
-
MDB_VAL_STRUCT_SIZE
public static final int MDB_VAL_STRUCT_SIZESize of aMDB_valpointer in bytes.- See Also:
-
STRUCT_FIELD_OFFSET_DATA
protected static final int STRUCT_FIELD_OFFSET_DATAOffset from a pointer of theMDB_val.mv_datafield.- See Also:
-
STRUCT_FIELD_OFFSET_SIZE
protected static final int STRUCT_FIELD_OFFSET_SIZEOffset from a pointer of theMDB_val.mv_sizefield.- See Also:
-
-
Constructor Details
-
BufferProxy
public BufferProxy()
-
-
Method Details
-
allocate
Allocate a new buffer suitable for passing toout(java.lang.Object, jnr.ffi.Pointer, long).- Returns:
- a buffer for passing to the
outmethod
-
compare
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).
- Parameters:
o1- left operando2- right operand- Returns:
- as per
Comparable
-
deallocate
Deallocate a buffer that was previously provided byallocate().- Parameters:
buff- the buffer to deallocate (required)
-
getBytes
Obtain a copy of the bytes contained within the passed buffer.- Parameters:
buffer- a non-null buffer created by this proxy instance- Returns:
- a copy of the bytes this buffer is currently representing
-
in
Called when theMDB_valshould be set to reflect the passed buffer. This buffer will have been created by end users, notallocate().- Parameters:
buffer- the buffer to write toMDB_valptr- the pointer to theMDB_valptrAddr- the address of theMDB_valpointer
-
in
Called when theMDB_valshould be set to reflect the passed buffer.- 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
Called when theMDB_valmay have changed and the passed buffer should be modified to reflect the newMDB_val.- Parameters:
buffer- the buffer to write toMDB_valptr- the pointer to theMDB_valptrAddr- the address of theMDB_valpointer- Returns:
- the buffer for
MDB_val
-