T
- buffer typepublic final class Cursor<T> extends Object implements AutoCloseable
Modifier and Type | Class and Description |
---|---|
static class |
Cursor.ClosedException
Cursor has already been closed.
|
static class |
Cursor.FullException
Cursor stack too deep - internal error.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close a cursor handle.
|
long |
count()
Return count of duplicates for current key.
|
void |
delete(PutFlags... f)
Delete current key/data pair.
|
boolean |
first()
Position at first key/data item.
|
boolean |
get(T key,
GetOp op)
Reposition the key/value buffers based on the passed key and operation.
|
T |
key()
Obtain the key.
|
boolean |
last()
Position at last key/data item.
|
boolean |
next()
Position at next data item.
|
boolean |
prev()
Position at previous data item.
|
boolean |
put(T key,
T val,
PutFlags... op)
Store by cursor.
|
void |
putMultiple(T key,
T val,
int elements,
PutFlags... op)
Put multiple values into the database in one
MDB_MULTIPLE
operation. |
void |
renew(Txn<T> newTxn)
Renew a cursor handle.
|
T |
reserve(T key,
int size,
PutFlags... op)
Reserve space for data of the given size, but don't copy the given val.
|
boolean |
seek(SeekOp op)
Reposition the key/value buffers based on the passed operation.
|
T |
val()
Obtain the value.
|
public void close()
The cursor handle will be freed and must not be used again after this call. Its transaction must still be live if it is a write-transaction.
close
in interface AutoCloseable
public long count()
This call is only valid on databases that support sorted duplicate data
items DbiFlags.MDB_DUPSORT
.
public void delete(PutFlags... f)
This function deletes the key/data pair to which the cursor refers.
f
- flags (either null or PutFlags.MDB_NODUPDATA
public boolean first()
public boolean get(T key, GetOp op)
key
- to search forop
- options for this operationpublic T key()
public boolean last()
public boolean next()
public boolean prev()
public boolean put(T key, T val, PutFlags... op)
This function stores key/data pairs into the database.
key
- key to storeval
- data to storeop
- options for this operationpublic void putMultiple(T key, T val, int elements, PutFlags... op)
MDB_MULTIPLE
operation.
The database must have been opened with DbiFlags.MDB_DUPFIXED
. The
buffer must contain fixed-sized values to be inserted. The size of each
element is calculated from the buffer's size divided by the given element
count. For example, to populate 10 X 4 byte integers at once, present a
buffer of 40 bytes and specify the element as 10.
key
- key to store in the database (not null)val
- value to store in the database (not null)elements
- number of elements contained in the passed value bufferop
- options for operation (must set MDB_MULTIPLE
)public void renew(Txn<T> newTxn)
A cursor is associated with a specific transaction and database. Cursors that are only used in read-only transactions may be re-used, to avoid unnecessary malloc/free overhead. The cursor may be associated with a new read-only transaction, and referencing the same database handle as it was created with. This may be done whether the previous transaction is live or dead.
newTxn
- transaction handlepublic T reserve(T key, int size, PutFlags... op)
This flag must not be specified if the database was opened with MDB_DUPSORT
key
- key to store in the database (not null)size
- size of the value to be stored in the database (not null)op
- options for this operationpublic boolean seek(SeekOp op)
op
- options for this operationpublic T val()
Copyright © 2016–2019 The LmdbJava Open Source Project. All rights reserved.