T
- buffer typepublic abstract class BufferProxy<T>
extends java.lang.Object
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
.
Modifier and Type | Field and Description |
---|---|
protected static int |
MDB_VAL_STRUCT_SIZE
Size of a
MDB_val pointer in bytes. |
protected static int |
STRUCT_FIELD_OFFSET_DATA
Offset from a pointer of the
MDB_val.mv_data field. |
protected static int |
STRUCT_FIELD_OFFSET_SIZE
Offset from a pointer of the
MDB_val.mv_size field. |
Constructor and Description |
---|
BufferProxy() |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
allocate()
Allocate a new buffer suitable for passing to
out(java.lang.Object, jnr.ffi.Pointer, long) . |
protected abstract int |
compare(T o1,
T o2)
Compare the two buffers.
|
protected abstract void |
deallocate(T buff)
Deallocate a buffer that was previously provided by
allocate() . |
protected abstract byte[] |
getBytes(T buffer)
Obtain a copy of the bytes contained within the passed buffer.
|
protected abstract void |
in(T buffer,
int size,
jnr.ffi.Pointer ptr,
long ptrAddr)
Called when the
MDB_val should be set to reflect the passed
buffer. |
protected abstract void |
in(T buffer,
jnr.ffi.Pointer ptr,
long ptrAddr)
Called when the
MDB_val should be set to reflect the passed
buffer. |
protected abstract T |
out(T 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 . |
protected static final int MDB_VAL_STRUCT_SIZE
MDB_val
pointer in bytes.protected static final int STRUCT_FIELD_OFFSET_DATA
MDB_val.mv_data
field.protected static final int STRUCT_FIELD_OFFSET_SIZE
MDB_val.mv_size
field.protected abstract T allocate()
out(java.lang.Object, jnr.ffi.Pointer, long)
.out
methodprotected abstract int compare(T o1, T o2)
Implemented as a protected method to discourage use of the buffer proxy in collections etc (given by design it wraps a temporary value only).
o1
- left operando2
- right operandComparable
protected abstract void deallocate(T buff)
allocate()
.buff
- the buffer to deallocate (required)protected abstract byte[] getBytes(T buffer)
buffer
- a non-null buffer created by this proxy instanceprotected abstract void in(T buffer, jnr.ffi.Pointer ptr, long ptrAddr)
MDB_val
should be set to reflect the passed
buffer. This buffer will have been created by end users, not
allocate()
.buffer
- the buffer to write to MDB_val
ptr
- the pointer to the MDB_val
ptrAddr
- the address of the MDB_val
pointerprotected abstract void in(T buffer, int size, jnr.ffi.Pointer ptr, long ptrAddr)
MDB_val
should be set to reflect the passed
buffer.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
pointerprotected abstract T out(T buffer, jnr.ffi.Pointer ptr, long ptrAddr)
MDB_val
may have changed and the passed buffer
should be modified to reflect the new MDB_val
.buffer
- the buffer to write to MDB_val
ptr
- the pointer to the MDB_val
ptrAddr
- the address of the MDB_val
pointerMDB_val
Copyright © 2016–2018 The LmdbJava Open Source Project. All rights reserved.