This is the lmdb Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 06:53:48 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
lmdb
Bindings to LMDB, the Lightning Memory-mapped Database.
Fernando Borretti <eudoxiahp@gmail.com>
Fernando Borretti <eudoxiahp@gmail.com>
(GIT git@github.com:antimer/lmdb.git)
MIT, see COPYING.
0.1
alexandria
(system).
trivial-utf-8
(system).
cl-reexport
(system).
mgl-pax
(system).
bordeaux-threads
(system).
osicat
(system).
trivial-features
(system).
trivial-garbage
(system).
src
(module).
Modules are listed depth-first from the system components tree.
lmdb/src
lmdb
(system).
package.lisp
(file).
liblmdb.lisp
(file).
lmdb.lisp
(file).
lmdb+.lisp
(file).
doc.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
lmdb/lmdb.asd
lmdb/src/package.lisp
lmdb/src/liblmdb.lisp
lmdb/src/lmdb.lisp
lmdb/src/lmdb+.lisp
lmdb/src/doc.lisp
lmdb/src/liblmdb.lisp
package.lisp
(file).
src
(module).
+append+
(constant).
+appenddup+
(constant).
+bad-dbi+
(constant).
+bad-rslot+
(constant).
+bad-txn+
(constant).
+bad-valsize+
(constant).
+corrupted+
(constant).
+cp-compact+
(constant).
+create+
(constant).
+current+
(constant).
+cursor-full+
(constant).
+dbs-full+
(constant).
+dupfixed+
(constant).
+dupsort+
(constant).
+fixedmap+
(constant).
+incompatible+
(constant).
+integerdup+
(constant).
+integerkey+
(constant).
+invalid+
(constant).
+keyexist+
(constant).
+last-errcode+
(constant).
+map-full+
(constant).
+map-resized+
(constant).
+mapasync+
(constant).
+multiple+
(constant).
+nodupdata+
(constant).
+nolock+
(constant).
+nomeminit+
(constant).
+nometasync+
(constant).
+nooverwrite+
(constant).
+nordahead+
(constant).
+nosubdir+
(constant).
+nosync+
(constant).
+notfound+
(constant).
+notls+
(constant).
+page-full+
(constant).
+page-notfound+
(constant).
+panic+
(constant).
+rdonly+
(constant).
+readers-full+
(constant).
+reserve+
(constant).
+reversedup+
(constant).
+reversekey+
(constant).
+success+
(constant).
+tls-full+
(constant).
+txn-full+
(constant).
+version-major+
(constant).
+version-minor+
(constant).
+version-mismatch+
(constant).
+version-patch+
(constant).
+writemap+
(constant).
cmp
(function).
cursor-close
(function).
cursor-count
(function).
cursor-dbi
(function).
cursor-del
(function).
cursor-get
(function).
cursor-open
(function).
cursor-put
(function).
cursor-renew
(function).
cursor-txn
(function).
dbi-close
(function).
dbi-flags
(function).
dbi-open
(function).
dcmp
(function).
defanonenum
(macro).
del
(function).
drop
(function).
env-close
(function).
env-copy
(function).
env-copy-2
(function).
env-copyfd
(function).
env-copyfd-2
(function).
env-create
(function).
env-get-fd
(function).
env-get-flags
(function).
env-get-maxkeysize
(function).
env-get-maxreaders
(function).
env-get-path
(function).
env-get-userctx
(function).
env-info
(function).
env-open
(function).
env-set-assert
(function).
env-set-flags
(function).
env-set-mapsize
(function).
env-set-maxdbs
(function).
env-set-maxreaders
(function).
env-set-userctx
(function).
env-stat
(function).
env-sync
(function).
envinfo-tclass
(class).
get
(function).
put
(function).
reader-check
(function).
reader-list
(function).
set-compare
(function).
set-dupsort
(function).
set-relctx
(function).
set-relfunc
(function).
stat
(function).
stat-tclass
(class).
strerror
(function).
txn-abort
(function).
txn-begin
(function).
txn-commit
(function).
txn-env
(function).
txn-id
(function).
txn-renew
(function).
txn-reset
(function).
val-tclass
(class).
version
(function).
lispify
(function).
lmdb/src/lmdb.lisp
liblmdb.lisp
(file).
src
(module).
*db-class*
(special variable).
*env*
(special variable).
*env-class*
(special variable).
*key-decoder*
(special variable).
*key-encoder*
(special variable).
*value-decoder*
(special variable).
*value-encoder*
(special variable).
abort-txn
(function).
check-for-stale-readers
(function).
close-env
(function).
commit-txn
(function).
cursor
(structure).
cursor-count
(function).
cursor-db
(reader).
(setf cursor-db)
(writer).
cursor-del
(function).
cursor-first
(function).
cursor-first-dup
(function).
cursor-key
(function).
cursor-key-value
(function).
cursor-last
(function).
cursor-last-dup
(function).
cursor-next
(function).
cursor-next-dup
(function).
cursor-next-nodup
(function).
cursor-prev
(function).
cursor-prev-dup
(function).
cursor-prev-nodup
(function).
cursor-put
(function).
cursor-renew
(function).
cursor-set-key
(function).
cursor-set-key-dup
(function).
cursor-set-range
(function).
cursor-set-range-dup
(function).
cursor-value
(function).
db
(class).
db-key-encoding
(reader method).
db-name
(reader method).
db-statistics
(function).
db-value-encoding
(reader method).
del
(function).
do-cursor
(macro).
do-cursor-dup
(macro).
do-db
(macro).
do-db-dup
(macro).
drop-db
(function).
encoding
(type).
env
(class).
env-flags
(reader method).
env-info
(function).
env-map-size
(reader method).
env-max-dbs
(reader method).
env-max-key-size
(function).
env-max-readers
(reader method).
env-mode
(reader method).
env-path
(reader method).
env-statistics
(function).
g3t
(function).
get-db
(function).
list-dups
(function).
lmdb-bad-dbi-error
(condition).
lmdb-bad-rslot-error
(condition).
lmdb-bad-txn-error
(condition).
lmdb-bad-valsize-error
(condition).
lmdb-binding-version
(function).
lmdb-corrupted-error
(condition).
lmdb-cursor-full-error
(condition).
lmdb-cursor-thread-error
(condition).
lmdb-cursor-uninitialized-error
(condition).
lmdb-dbs-full-error
(condition).
lmdb-error
(function).
lmdb-error
(condition).
lmdb-foreign-version
(function).
lmdb-illegal-access-to-parent-txn-error
(condition).
lmdb-incompatible-error
(condition).
lmdb-invalid-error
(condition).
lmdb-key-exists-error
(condition).
lmdb-map-full-error
(condition).
lmdb-map-resized-error
(condition).
lmdb-not-found-error
(condition).
lmdb-page-full-error
(condition).
lmdb-page-not-found-error
(condition).
lmdb-panic-error
(condition).
lmdb-readers-full-error
(condition).
lmdb-serious-condition
(condition).
lmdb-txn-full-error
(condition).
lmdb-txn-read-only-error
(condition).
lmdb-version-mismatch-error
(condition).
mdb-val-to-octets
(function).
mdb-val-to-string
(function).
mdb-val-to-uint64
(function).
octets
(type).
octets-to-string
(function).
octets-to-uint64
(function).
open-env
(function).
open-env-p
(function).
open-txn-p
(function).
print-object
(method).
print-object
(method).
put
(function).
renew-txn
(function).
reset-txn
(function).
string-to-octets
(function).
sync-env
(function).
txn-id
(function).
uint64-to-octets
(function).
with-cursor
(macro).
with-env
(macro).
with-implicit-cursor
(macro).
with-mdb-val-slots
(macro).
with-temporary-env
(macro).
with-txn
(macro).
%close-cursor
(function).
%cursorp
(function).
%dbi
(reader method).
%envp
(function).
%make-env
(function).
%open-cursor
(function).
%open-txn-p
(function).
%txna
(function).
%txnp
(function).
*default-cursor*
(special variable).
*endianness*
(special variable).
*open-envs*
(special variable).
*open-envs-lock*
(special variable).
*txn*
(special variable).
+cursor-thread+
(special variable).
+cursor-uninitialized+
(special variable).
+eacces+
(special variable).
+eagain+
(special variable).
+einval+
(special variable).
+enoent+
(special variable).
+illegal-access-to-parent-txn+
(special variable).
+n-alignment-bits+
(constant).
+n-word-bits+
(constant).
+null-pointer+
(constant).
+txn-read-only+
(special variable).
@active-transaction
(special variable).
@default-cursor
(special variable).
@dupsort
(special variable).
@lmdb-manual
(special variable).
@lmdb/additional-conditions
(special variable).
@lmdb/basic-cursor-operations
(special variable).
@lmdb/basic-operations
(special variable).
@lmdb/conditions
(special variable).
@lmdb/cursors
(special variable).
@lmdb/database-api
(special variable).
@lmdb/databases
(special variable).
@lmdb/design-and-implementation
(special variable).
@lmdb/deviations-from-the-lmdb-api
(special variable).
@lmdb/encodings
(special variable).
@lmdb/env-reference
(special variable).
@lmdb/environments
(special variable).
@lmdb/error-code-conditions
(special variable).
@lmdb/introduction
(special variable).
@lmdb/links
(special variable).
@lmdb/misc-cursor
(special variable).
@lmdb/misc-env
(special variable).
@lmdb/nesting-transactions
(special variable).
@lmdb/opening-and-closing-env
(special variable).
@lmdb/overriding-encodings
(special variable).
@lmdb/positioning-cursors
(special variable).
@lmdb/safety
(special variable).
@lmdb/the-unnamed-database
(special variable).
@lmdb/transactions
(special variable).
@lmdb/version
(special variable).
abortable-txn-p
(function).
active-txn-in-env
(function).
aligned-pointer-to-fixnum
(function).
assert-error
(macro).
async-signal-safe
(macro).
call-with-cursor
(function).
call-with-implicit-cursor
(function).
call-with-temporary-env
(function).
call-with-txn
(function).
check-cursor
(function).
check-for-stale-readers*
(function).
check-mdb-file-not-open-in-same-process
(function).
check-no-active-transaction
(function).
clear-txn-reset-p
(function).
close-txn
(function).
copy-cursor
(function).
copy-foreign-value
(function).
copy-txn
(function).
cursor-%cursorp
(reader).
(setf cursor-%cursorp)
(writer).
cursor-env
(reader).
(setf cursor-env)
(writer).
cursor-p
(function).
cursor-thread
(reader).
(setf cursor-thread)
(writer).
cursor-txn
(reader).
(setf cursor-txn)
(writer).
db-env
(reader method).
db-flags
(function).
decode-data
(function).
decode-key
(macro).
decode-value
(macro).
deregister-open-env
(function).
encode-data
(function).
encode-key
(macro).
encode-value
(macro).
env-db-lock
(reader method).
env-db-name-to-dbi
(reader method).
env-enter-txn
(function).
env-flag-list-to-int
(function).
env-leave-txn
(function).
env-n-txns
(reader method).
env-prevent-txns
(function).
errno-value
(function).
finalize-env
(function).
fixnum-to-aligned-pointer
(function).
init-%val
(function).
lmdb-error-control-string
(reader method).
lmdb-error-error-code
(reader method).
lmdb-error-format-args
(reader method).
make-cursor
(function).
make-txn
(function).
maybe-abort-txn
(function).
maybe-commit-txn
(function).
mdb-truename
(function).
memcpy
(function).
octet
(type).
open-%txnp
(function).
open-%txnp-for-db
(function).
open-%txnp-for-env
(function).
parent-txn
(function).
random-string
(function).
read-only-txn-p
(function).
register-open-env
(function).
set-txn-reset-p
(function).
shadow-get
(macro).
strerror
(function).
txn
(structure).
txn-%txna
(reader).
(setf txn-%txna)
(writer).
txn-enclosing-txn
(reader).
(setf txn-enclosing-txn)
(writer).
txn-env
(reader).
(setf txn-env)
(writer).
txn-flags
(reader).
(setf txn-flags)
(writer).
txn-p
(function).
txn-reset-p
(function).
unwind-protect*
(macro).
with-empty-val
(macro).
with-interrupts
(macro).
with-val
(macro).
without-interrupts
(macro).
lmdb/src/doc.lisp
lmdb+.lisp
(file).
src
(module).
pax-pages
(function).
pax-sections
(function).
Packages are listed by definition order.
liblmdb
The low-level LMDB interface.
cffi
.
common-lisp
.
+append+
(constant).
+appenddup+
(constant).
+bad-dbi+
(constant).
+bad-rslot+
(constant).
+bad-txn+
(constant).
+bad-valsize+
(constant).
+corrupted+
(constant).
+cp-compact+
(constant).
+create+
(constant).
+current+
(constant).
+cursor-full+
(constant).
+dbs-full+
(constant).
+dupfixed+
(constant).
+dupsort+
(constant).
+fixedmap+
(constant).
+incompatible+
(constant).
+integerdup+
(constant).
+integerkey+
(constant).
+invalid+
(constant).
+keyexist+
(constant).
+last-errcode+
(constant).
+map-full+
(constant).
+map-resized+
(constant).
+mapasync+
(constant).
+multiple+
(constant).
+nodupdata+
(constant).
+nolock+
(constant).
+nomeminit+
(constant).
+nometasync+
(constant).
+nooverwrite+
(constant).
+nordahead+
(constant).
+nosubdir+
(constant).
+nosync+
(constant).
+notfound+
(constant).
+notls+
(constant).
+page-full+
(constant).
+page-notfound+
(constant).
+panic+
(constant).
+rdonly+
(constant).
+readers-full+
(constant).
+reserve+
(constant).
+reversedup+
(constant).
+reversekey+
(constant).
+success+
(constant).
+tls-full+
(constant).
+txn-full+
(constant).
+version-major+
(constant).
+version-minor+
(constant).
+version-mismatch+
(constant).
+version-patch+
(constant).
+writemap+
(constant).
cmp
(function).
cursor-close
(function).
cursor-count
(function).
cursor-dbi
(function).
cursor-del
(function).
cursor-get
(function).
cursor-open
(function).
cursor-put
(function).
cursor-renew
(function).
cursor-txn
(function).
dbi-close
(function).
dbi-flags
(function).
dbi-open
(function).
dcmp
(function).
defanonenum
(macro).
del
(function).
drop
(function).
env-close
(function).
env-copy
(function).
env-copy-2
(function).
env-copyfd
(function).
env-copyfd-2
(function).
env-create
(function).
env-get-fd
(function).
env-get-flags
(function).
env-get-maxkeysize
(function).
env-get-maxreaders
(function).
env-get-path
(function).
env-get-userctx
(function).
env-info
(function).
env-open
(function).
env-set-assert
(function).
env-set-flags
(function).
env-set-mapsize
(function).
env-set-maxdbs
(function).
env-set-maxreaders
(function).
env-set-userctx
(function).
env-stat
(function).
env-sync
(function).
envinfo-tclass
(class).
get
(function).
put
(function).
reader-check
(function).
reader-list
(function).
set-compare
(function).
set-dupsort
(function).
set-relctx
(function).
set-relfunc
(function).
stat
(function).
stat-tclass
(class).
strerror
(function).
txn-abort
(function).
txn-begin
(function).
txn-commit
(function).
txn-env
(function).
txn-id
(function).
txn-renew
(function).
txn-reset
(function).
val-tclass
(class).
version
(function).
lispify
(function).
lmdb
See LMDB:@LMDB-MANUAL.
common-lisp
.
editor-hints.named-readtables
.
mgl-pax
.
pythonic-string-reader
.
*db-class*
(special variable).
*env*
(special variable).
*env-class*
(special variable).
*key-decoder*
(special variable).
*key-encoder*
(special variable).
*value-decoder*
(special variable).
*value-encoder*
(special variable).
abort-txn
(function).
check-for-stale-readers
(function).
close-env
(function).
commit-txn
(function).
cursor
(structure).
cursor-count
(function).
cursor-db
(reader).
(setf cursor-db)
(writer).
cursor-del
(function).
cursor-first
(function).
cursor-first-dup
(function).
cursor-key
(function).
cursor-key-value
(function).
cursor-last
(function).
cursor-last-dup
(function).
cursor-next
(function).
cursor-next-dup
(function).
cursor-next-nodup
(function).
cursor-prev
(function).
cursor-prev-dup
(function).
cursor-prev-nodup
(function).
cursor-put
(function).
cursor-renew
(function).
cursor-set-key
(function).
cursor-set-key-dup
(function).
cursor-set-range
(function).
cursor-set-range-dup
(function).
cursor-value
(function).
db
(class).
db-key-encoding
(generic reader).
db-name
(generic reader).
db-statistics
(function).
db-value-encoding
(generic reader).
del
(function).
do-cursor
(macro).
do-cursor-dup
(macro).
do-db
(macro).
do-db-dup
(macro).
drop-db
(function).
encoding
(type).
env
(class).
env-flags
(generic reader).
env-info
(function).
env-map-size
(generic reader).
env-max-dbs
(generic reader).
env-max-key-size
(function).
env-max-readers
(generic reader).
env-mode
(generic reader).
env-path
(generic reader).
env-statistics
(function).
g3t
(function).
get-db
(function).
list-dups
(function).
lmdb-bad-dbi-error
(condition).
lmdb-bad-rslot-error
(condition).
lmdb-bad-txn-error
(condition).
lmdb-bad-valsize-error
(condition).
lmdb-binding-version
(function).
lmdb-corrupted-error
(condition).
lmdb-cursor-full-error
(condition).
lmdb-cursor-thread-error
(condition).
lmdb-cursor-uninitialized-error
(condition).
lmdb-dbs-full-error
(condition).
lmdb-error
(function).
lmdb-error
(condition).
lmdb-foreign-version
(function).
lmdb-illegal-access-to-parent-txn-error
(condition).
lmdb-incompatible-error
(condition).
lmdb-invalid-error
(condition).
lmdb-key-exists-error
(condition).
lmdb-map-full-error
(condition).
lmdb-map-resized-error
(condition).
lmdb-not-found-error
(condition).
lmdb-page-full-error
(condition).
lmdb-page-not-found-error
(condition).
lmdb-panic-error
(condition).
lmdb-readers-full-error
(condition).
lmdb-serious-condition
(condition).
lmdb-txn-full-error
(condition).
lmdb-txn-read-only-error
(condition).
lmdb-version-mismatch-error
(condition).
mdb-val-to-octets
(function).
mdb-val-to-string
(function).
mdb-val-to-uint64
(function).
octets
(type).
octets-to-string
(function).
octets-to-uint64
(function).
open-env
(function).
open-env-p
(function).
open-txn-p
(function).
put
(function).
renew-txn
(function).
reset-txn
(function).
string-to-octets
(function).
sync-env
(function).
txn-id
(function).
uint64-to-octets
(function).
with-cursor
(macro).
with-env
(macro).
with-implicit-cursor
(macro).
with-mdb-val-slots
(macro).
with-temporary-env
(macro).
with-txn
(macro).
%close-cursor
(function).
%cursorp
(function).
%dbi
(generic reader).
%envp
(function).
%make-env
(function).
%open-cursor
(function).
%open-txn-p
(function).
%txna
(function).
%txnp
(function).
*default-cursor*
(special variable).
*endianness*
(special variable).
*open-envs*
(special variable).
*open-envs-lock*
(special variable).
*txn*
(special variable).
+cursor-thread+
(special variable).
+cursor-uninitialized+
(special variable).
+eacces+
(special variable).
+eagain+
(special variable).
+einval+
(special variable).
+enoent+
(special variable).
+illegal-access-to-parent-txn+
(special variable).
+n-alignment-bits+
(constant).
+n-word-bits+
(constant).
+null-pointer+
(constant).
+txn-read-only+
(special variable).
@active-transaction
(special variable).
@default-cursor
(special variable).
@dupsort
(special variable).
@lmdb-manual
(special variable).
@lmdb/additional-conditions
(special variable).
@lmdb/basic-cursor-operations
(special variable).
@lmdb/basic-operations
(special variable).
@lmdb/conditions
(special variable).
@lmdb/cursors
(special variable).
@lmdb/database-api
(special variable).
@lmdb/databases
(special variable).
@lmdb/design-and-implementation
(special variable).
@lmdb/deviations-from-the-lmdb-api
(special variable).
@lmdb/encodings
(special variable).
@lmdb/env-reference
(special variable).
@lmdb/environments
(special variable).
@lmdb/error-code-conditions
(special variable).
@lmdb/introduction
(special variable).
@lmdb/links
(special variable).
@lmdb/misc-cursor
(special variable).
@lmdb/misc-env
(special variable).
@lmdb/nesting-transactions
(special variable).
@lmdb/opening-and-closing-env
(special variable).
@lmdb/overriding-encodings
(special variable).
@lmdb/positioning-cursors
(special variable).
@lmdb/safety
(special variable).
@lmdb/the-unnamed-database
(special variable).
@lmdb/transactions
(special variable).
@lmdb/version
(special variable).
abortable-txn-p
(function).
active-txn-in-env
(function).
aligned-pointer-to-fixnum
(function).
assert-error
(macro).
async-signal-safe
(macro).
call-with-cursor
(function).
call-with-implicit-cursor
(function).
call-with-temporary-env
(function).
call-with-txn
(function).
check-cursor
(function).
check-for-stale-readers*
(function).
check-mdb-file-not-open-in-same-process
(function).
check-no-active-transaction
(function).
clear-txn-reset-p
(function).
close-txn
(function).
copy-cursor
(function).
copy-foreign-value
(function).
copy-txn
(function).
cursor-%cursorp
(reader).
(setf cursor-%cursorp)
(writer).
cursor-env
(reader).
(setf cursor-env)
(writer).
cursor-p
(function).
cursor-thread
(reader).
(setf cursor-thread)
(writer).
cursor-txn
(reader).
(setf cursor-txn)
(writer).
db-env
(generic reader).
db-flags
(function).
decode-data
(function).
decode-key
(macro).
decode-value
(macro).
deregister-open-env
(function).
encode-data
(function).
encode-key
(macro).
encode-value
(macro).
env-db-lock
(generic reader).
env-db-name-to-dbi
(generic reader).
env-enter-txn
(function).
env-flag-list-to-int
(function).
env-leave-txn
(function).
env-n-txns
(generic reader).
env-prevent-txns
(function).
errno-value
(function).
finalize-env
(function).
fixnum-to-aligned-pointer
(function).
init-%val
(function).
lmdb-error-control-string
(generic reader).
lmdb-error-error-code
(generic reader).
lmdb-error-format-args
(generic reader).
make-cursor
(function).
make-txn
(function).
maybe-abort-txn
(function).
maybe-commit-txn
(function).
mdb-truename
(function).
memcpy
(function).
octet
(type).
open-%txnp
(function).
open-%txnp-for-db
(function).
open-%txnp-for-env
(function).
parent-txn
(function).
pax-pages
(function).
pax-sections
(function).
random-string
(function).
read-only-txn-p
(function).
register-open-env
(function).
set-txn-reset-p
(function).
shadow-get
(macro).
strerror
(function).
txn
(structure).
txn-%txna
(reader).
(setf txn-%txna)
(writer).
txn-enclosing-txn
(reader).
(setf txn-enclosing-txn)
(writer).
txn-env
(reader).
(setf txn-env)
(writer).
txn-flags
(reader).
(setf txn-flags)
(writer).
txn-p
(function).
txn-reset-p
(function).
unwind-protect*
(macro).
with-empty-val
(macro).
with-interrupts
(macro).
with-val
(macro).
without-interrupts
(macro).
Definitions are sorted by export status, category, package, and then by lexicographic order.
The default class that GET-DB instantiates. Must a subclass of DB. This provides a way to associate application specific data with DB objects.
The default ENV for macros and function that take an environment argument.
The default class OPEN-ENV instaniates. Must be a subclass of ENV. This provides a way to associate application specific data with ENV objects.
A function designator, NIL or an ENCODING. If non-NIL, it is
called with a single MDB-VAL argument (see WITH-MDB-VAL-SLOTS), that
holds a pointer to data to be decoded and its size. This function is
called whenever a key is to be decoded and overrides the
KEY-ENCODING argument of GET-DB.
For example, if we are only interested in the length of the value
and want to avoid creating a lisp vector on the heap, we can do
this:
“‘
(with-temporary-env (*env*)
(let ((db (get-db "test")))
(with-txn (:write t)
(put db "key1" "abc")
(let ((*value-decoder* (lambda (mdb-val)
(with-mdb-val-slots (%bytes size mdb-val)
(declare (ignore %bytes))
;; Take null termination into account.
(1- size)))))
(g3t db "key1")))))
=> 3
=> T
“‘
A function designator, NIL or an ENCODING. If non-NIL, it overrides the encoding method determined by KEY-ENCODING (see GET-DB). It is called with a single argument, the key, when it is to be converted to an octet vector.
Like *KEY-DECODER*, but for values.
Apart from performing actual decoding, the main purpose of *VALUE-DECODER*, one can also pass the foreign data on to other foreign functions such as ‘write()‘ directly from the decoder function and returning a constant such as T to avoid consing.
Like *KEY-ENCODER*, but for values.
Converts anonymous enums to defconstants.
Iterate over key-value pairs starting from the position of CURSOR.
If CURSOR is not positioned then no key-value pairs will be seen. If
FROM-END, then iterate with CURSOR-PREV instead of CURSOR-NEXT. If
NODUP, then make that CURSOR-PREV-NODUP and CURSOR-NEXT-NODUP.
If CURSOR is NIL, the @DEFAULT-CURSOR is used.
If NODUP and not FROM-END, then the first duplicate of each key will
be seen. If NODUP and FROM-END, then the last duplicate of each key
will be seen.
To iterate over all key-value pairs with keys >= 7:
“‘
(with-cursor (cursor db)
(cursor-set-key 7 cursor)
(do-cursor (key value cursor)
(print (cons key value))))
“‘
Iterate over duplicate values with starting from the position of
CURSOR. If CURSOR is not positioned then no values will be seen. If
FROM-END, then iterate with CURSOR-PREV-DUP instead of
CURSOR-NEXT-DUP.
If CURSOR is NIL, the @DEFAULT-CURSOR is used.
To iterate over all values that not smaller than #(3 4 5),
associated with the key 7:
“‘
(with-cursor (cursor db)
(cursor-set-key-dup cursor 7 #(3 4 5))
(do-cursor-dup (value cursor)
(print value)))
“‘
Iterate over all keys and values in DB. If NODUP, then all but the
first (or last if FROM-END) value for each key are skipped. If
FROM-END, then iterate in reverse order.
To iterate over all values in DB:
“‘
(do-db (key value db)
(print (cons key value)))
“‘
This macro establishes a @DEFAULT-CURSOR.
Iterate over all values associated with KEY in DB. If FROM-END,
then iteration starts at the largest value.
To iterate over all values associated with the key 7:
“‘
(do-db-dup (value db 7)
(print value))
“‘
This macro establishes a @DEFAULT-CURSOR.
Bind VAR to a fresh CURSOR on DB. Execute BODY, then close the
cursor. Within the dynamic extent of BODY, this will be the
@DEFAULT-CURSOR. The cursor is tied to the @ACTIVE-TRANSACTION.
LMDB-CURSOR-THREAD-ERROR is signalled if the cursor is accessed from
threads other than the one in which it was created.
Wraps [mdb_cursor_open()](http://www.lmdb.tech/doc/group__mdb.html#ga9ff5d7bd42557fd5ee235dc1d62613aa) and [mdb_cursor_close()](http://www.lmdb.tech/doc/group__mdb.html#gad685f5d73c052715c7bd859cc4c05188).
Bind the variable ENV to a new enviroment returned by OPEN-ENV
called with PATH and OPEN-ENV-ARGS, execute BODY, and CLOSE-ENV. The
following example binds the default environment:
“‘
(with-env (*env* "/tmp/lmdb-test" :if-does-not-exist :create)
...)
“‘
Like WITH-CURSOR but the cursor object is not accessible directly,
only through the @DEFAULT-CURSOR mechanism. The cursor is
stack-allocated, which eliminates the consing of WITH-CURSOR. Note
that stack allocation of cursors in WITH-CURSOR would risk data
corruption if the cursor were accessed beyond its dynamic extent.
Use WITH-IMPLICIT-CURSOR instead of WITH-CURSOR if a single cursor
at a time will suffice. Conversely, use WITH-CURSOR if a second
cursor is needed. That is, use
“‘
(with-implicit-cursor (db)
(cursor-set-key 1))
“‘
but when two cursors iterate in an interleaved manner, use
WITH-CURSOR:
“‘
(with-cursor (c1 db)
(with-cursor (c2 db)
(cursor-first c1)
(cursor-last c2)
(if (some-pred (cursor-value c1) (cursor-value c2))
(cursor-next c1)
(cursor-prev c2))
...))
“‘
Wraps [mdb_cursor_open()](http://www.lmdb.tech/doc/group__mdb.html#ga9ff5d7bd42557fd5ee235dc1d62613aa) and [mdb_cursor_close()](http://www.lmdb.tech/doc/group__mdb.html#gad685f5d73c052715c7bd859cc4c05188).
Bind %BYTES and SIZE locally to the corresponding slots of MDB-VAL. MDB-VAL is an opaque handle for a foreign ‘MDB_val‘ struct, that holds the pointer to a byte array and the number of bytes in the array. This macro is needed to access the foreign data in a function used as *KEY-DECODER* or *VALUE-DECODER*. MDB-VAL is dynamic extent, so don’t hold on to it. Also, the pointer to which %BYTES is bound is valid only within the context of current top-level transaction.
Run BODY with an open temporary environment bound to ENV. In more
detail, create an environment in a fresh temporary directory in an
OS specific location. OPEN-ENV-ARGS is a list of keyword arguments
and values for OPEN-ENV. This macro is intended for testing and
examples.
“‘
(with-temporary-env (*env*)
(let ((db (get-db "test")))
(with-txn (:write t)
(put db "k1" #(2 3))
(print (g3t db "k1")) ; => #(2 3)
(del db "k1"))))
“‘
Since data corruption in temporary environments is not a concern, unlike WITH-ENV, WITH-TEMPORARY-ENV closes the environment even if it was opened with :SYNCHRONIZED NIL (see OPEN-ENV and CLOSE-ENV).
Start a transaction in ENV, execute BODY. Then, if the transaction
is open (see OPEN-TXN-P) and BODY returned normally, attempt to
commit the transaction. Next, if BODY performed a non-local exit or
committing failed, but the transaction is still open, then abort it.
It is explicitly allowed to call COMMIT-TXN or ABORT-TXN within
WITH-TXN.
Transactions provide ACID guarantees (with SYNC and META-SYNC both
on). They span the entire environment, they are not specific to
individual DB.
- If WRITE is NIL, the transaction is read-only and no writes (e.g.
PUT) may be performed in the transaction. On the flipside, many
read-only transactions can run concurrently (see ENV-MAX-READERS),
while write transactions are mutually exclusive. Furthermore, the
single write transaction can also run concurrently with read
transactions, just keep in mind that read transactions hold on to
the state of the environment at the time of their creation and
thus prevent pages since replaced from being reused.
- If IGNORE-PARENT is true, then in an enclosing WITH-TXN, instead
of creating a child transaction, start an independent transaction.
- If SYNC is NIL, then no flushing of buffers will take place after
a commit as if the environment had been opened with :SYNC NIL.
- Likewise, META-SYNC is the per-transaction equivalent of the
OPEN-ENV’s META-SYNC.
Also see @LMDB/NESTING-TRANSACTIONS.
Wraps [mdb_txn_begin()](http://www.lmdb.tech/doc/group__mdb.html#gad7ea55da06b77513609efebd44b26920).
Close TXN by discarding all updates performed, which will then not
be visible to either parent or future transactions. Aborting an
already closed transaction is a noop. Always succeeds.
Wraps [mdb_txn_abort()](http://www.lmdb.tech/doc/group__mdb.html#ga73a5938ae4c3239ee11efa07eb22b882).
Check for stale entries in the reader lock table. See
[Caveats](http://www.lmdb.tech/doc/). This function is called
automatically by OPEN-ENV. If other OS processes or threads
accessing ENV abort without closing read transactions, call this
function periodically to get rid off them. Alternatively, close all
environments accessing the data file.
Wraps [mdb_reader_check()](http://www.lmdb.tech/doc/group__mdb.html#ga366923d08bb384b3d9580a98edf5d668).
Close ENV and free the memory. Closing an already closed ENV has no effect.
Since accessing @LMDB/TRANSACTIONS, @LMDB/DATABASES and
@LMDB/CURSORS after closing their environment would risk database
curruption, CLOSE-ENV makes sure that they are not in use. There are
two ways this can happen:
- If ENV was opened :SYNCHRONIZED (see OPEN-ENV), then CLOSE-ENV
waits until there are no @ACTIVE-TRANSACTIONs in ENV before
closing it. This requires synchronization and introduces some
overhead, which might be noticable for workloads involving lots of
quick read transactions. It is an LMDB-ERROR to attempt to close
an environment in a WITH-TXN to avoid deadlocks.
- On the other hand, if SYNCHRONIZED was NIL, then - unless FORCE is
true - calling CLOSE-ENV signals an LMDB-ERROR to avoid the
@LMDB/SAFETY issues involved in closing the environment.
Environments opened with :SYNCHRONIZED NIL are only closed when
they are garbage collected and their finalizer is run. Still, for
production it might be worth it to gain the last bit of
performance.
Wraps [mdb_env_close()](http://www.lmdb.tech/doc/group__mdb.html#ga4366c43ada8874588b6a62fbda2d1e95).
Commit the innermost enclosig transaction (or @ACTIVE-TRANSACTION
belonging to ENV if ENV is specified) or signal an error if it is
not open. If TXN is not nested in another transaction, committing
makes updates performed visible to future transactions. If TXN is a
child transaction, then committing makes updates visible to its
parent only. For read-only transactions, committing releases the
reference to a historical version environment, allowing reuse of
pages replaced since.
Wraps [mdb_txn_commit()](http://www.lmdb.tech/doc/group__mdb.html#ga846fbd6f46105617ac9f4d76476f6597).
Return the number of duplicate values for the current key of
CURSOR. If CURSOR-DB doesn’t have @DUPSORT, LMDB-INCOMPATIBLE-ERROR
is signalled. If CURSOR is not initialized,
LMDB-CURSOR-UNINITIALIZED-ERROR is signalled.
Wraps [mdb_cursor_count()](http://www.lmdb.tech/doc/group__mdb.html#ga4041fd1e1862c6b7d5f10590b86ffbe2).
Delete the key-value pair CURSOR is positioned at. This does not
make the cursor uninitialized, so operations such as CURSOR-NEXT can
still be used on it. Both CURSOR-NEXT and CURSOR-KEY-VALUE will
return the same record after this operation. If CURSOR is not
initialized, LMDB-CURSOR-UNINITIALIZED-ERROR is signalled. Returns
no values.
If DELETE-DUPS, delete all duplicate values that belong to the
current key. With DELETE-DUPS, CURSOR-DB must have @DUPSORT, else
LMDB-INCOMPATIBLE-ERROR is signalled.
May signal LMDB-CURSOR-UNINITIALIZED-ERROR,
LMDB-TXN-READ-ONLY-ERROR.
Wraps [mdb_cursor_del()](http://www.lmdb.tech/doc/group__mdb.html#ga26a52d3efcfd72e5bf6bd6960bf75f95).
Move CURSOR to the first key of its database. Return the key, the
value and T, or NIL if the database is empty. If @DUPSORT, position
CURSOR on the first value of the first key.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_FIRST](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the first duplicate value of the current key. Return
the value and T. Return NIL if CURSOR is not positioned.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_FIRST_DUP](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Return the key CURSOR is positioned at and T. Return NIL if CURSOR
is uninitialized.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_GET_CURRENT](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Return the key and value CURSOR is positioned at and T. Return NIL
if CURSOR is uninitialized.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_GET_CURRENT](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the last key of its database. Return the key, the
value and T, or NIL if the database is empty. If @DUPSORT, position
CURSOR on the last value of the last key.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_LAST](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the last duplicate value of the current key. Return
the value and T. Return NIL if CURSOR is not positioned.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_LAST_DUP](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the next key-value pair of its database and return
the key, the value, and T. Return NIL if there is no next item. If
@DUPSORT, position CURSOR on the next value of the current key if
exists, else the first value of next key. If CURSOR is
uninitialized, then CURSOR-FIRST is called on it first.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_NEXT](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the next value of current key pair of its database.
Return the value and T. Return NIL if there is no next value. If
CURSOR is uninitialized, then CURSOR-FIRST is called on it first.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_NEXT_DUP](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the first value of next key pair of its
database (skipping over duplicate values of the current key). Return
the key, the value and T. Return NIL if there is no next item. If
CURSOR is uninitialized, then CURSOR-FIRST is called on it first.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_NEXT_NODUP](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the previous key-value pair of its database.
Return the key, the value and T. Return NIL if there is no previous
item. If @DUPSORT, position CURSOR on the previous value of the
current key if exists, else the last value of previous key. If
CURSOR is uninitialized, then CURSOR-LAST is called on it first.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_PREV](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the previous duplicate value of current key pair of
its database. Return the value and T. Return NIL if there is no prev
value. If CURSOR is uninitialized, then CURSOR-LAST is called on it
first.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_PREV_DUP](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the last value of previous key pair of its
database (skipping over duplicate values of the current and the
previous key). Return the key, the value, and T. Return NIL if
there is no prev item. If CURSOR is uninitialized, then CURSOR-LAST
is called on it first.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_PREV_NODUP](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Like PUT, store key-value pairs into CURSOR’s database.
CURSOR is positioned at the new item, or on failure usually near it.
Return VALUE.
- CURRENT: Replace the item at the current cursor position. KEY must
still be provided, and must match it. If using sorted
duplicates (@DUPSORT), VALUE must still sort into the same place.
This is intended to be used when the new data is the same size as
the old. Otherwise it will simply perform a delete of the old
record followed by an insert.
- OVERWRITE: If NIL, signal LMDB-KEY-EXISTS-ERROR if KEY already
appears in CURSOR-DB.
- DUPDATA: If NIL, signal LMDB-KEY-EXISTS-ERROR if the KEY, VALUE
pair already appears in DB. Has no effect if CURSOR-DB doesn’t
have @DUPSORT.
- APPEND: Append the KEY, VALUE pair to the end of CURSOR-DB instead
of finding KEY’s location in the B+ tree by performing
comparisons. The client effectively promises that keys are
inserted in sort order, which allows for fast bulk loading. If the
promise is broken, LMDB-KEY-EXISTS-ERROR is signalled.
- APPEND-DUP: The client promises that duplicate values are inserted
in sort order. If the promise is broken, LMDB-KEY-EXISTS-ERROR is
signalled.
May signal LMDB-MAP-FULL-ERROR, LMDB-TXN-FULL-ERROR,
LMDB-TXN-READ-ONLY-ERROR.
Wraps [mdb_cursor_put()](http://www.lmdb.tech/doc/group__mdb.html#ga1f83ccb40011837ff37cc32be01ad91e).
Associate CURSOR with the @ACTIVE-TRANSACTION (which must be
read-only) as if it had been created with that transaction to begin
with to avoid allocation overhead. CURSOR-DB stays the same. This
may be done whether the previous transaction is open or closed (see
OPEN-TXN-P). No values are returned.
Wraps [mdb_cursor_renew()](http://www.lmdb.tech/doc/group__mdb.html#gac8b57befb68793070c85ea813df481af).
Move CURSOR to KEY of its database. Return the corresponding value
and T. Return NIL if KEY was not found. If @DUPSORT, position CURSOR
on the first value of KEY.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_SET_KEY](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Move CURSOR to the KEY, VALUE pair of its database and return T on
success. Return NIL if the pair was not found.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_GET_BOTH](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Position CURSOR on the first key equal to or greater than KEY.
Return the found key, the value and T. Return NIL if KEY was not
found. If @DUPSORT, position CURSOR on the first value of the found
key.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_SET_RANGE](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Position CURSOR exactly at KEY on the first value greater than or
equal to VALUE. Return the value at the position and T on success,
or NIL if there is no such value associated with KEY.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_GET_BOTH_RANGE](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Return the value CURSOR is positioned at and T. Return NIL if
CURSOR is uninitialized.
Wraps [mdb_cursor_get()](http://www.lmdb.tech/doc/group__mdb.html#ga48df35fb102536b32dfbb801a47b4cb0) with [MDB_GET_CURRENT](http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127).
Return statistics about the database.
Wraps [mdb_stat()](http://www.lmdb.tech/doc/group__mdb.html#gae6c1069febe94299769dbdd032fadef6).
Delete KEY from DB. Returns T if data was deleted, NIL otherwise.
If DB supports sorted duplicates (@DUPSORT), then VALUE is taken
into account: if it’s NIL, then all duplicate values for KEY are
deleted, if it’s not NIL, then only the matching value. May signal
LMDB-TXN-READ-ONLY-ERROR.
Wraps [mdb_del()](http://www.lmdb.tech/doc/group__mdb.html#gab8182f9360ea69ac0afd4a4eaab1ddb0).
Empty the database with NAME in the environment denoted by PATH. If
DELETE, then delete the database. Since closing a database is
dangerous (see GET-DB), DROP-DB opens and closes the environment
itself.
Wraps [mdb_drop()](http://www.lmdb.tech/doc/group__mdb.html#gab966fab3840fc54a6571dfb32b00f2db).
Return information about ENV as a plist.
- :MAP-ADDRESS: Address of memory map, if fixed (see OPEN-ENV’s
FIXED-MAP).
- :MAP-SIZE: Size of the memory map in bytes.
- :LAST-PAGE-NUMBER: Id of the last used page.
- :LAST-TXN-ID: Id of the last committed transaction.
- :MAXIMUM-READERS: The number of reader slots.
- :N-READERS: The number of reader slots current used.
Wraps [mdb_env_info()](http://www.lmdb.tech/doc/group__mdb.html#ga18769362c7e7d6cf91889a028a5c5947).
Return the maximum size of keys and @DUPSORT data in bytes. Depends
on the compile-time constant ‘MDB_MAXKEYSIZE‘ in the C library. The
default is 511. If this limit is exceeded LMDB-BAD-VALSIZE-ERROR is
signalled.
Wraps [mdb_env_get_maxkeysize()](http://www.lmdb.tech/doc/group__mdb.html#gaaf0be004f33828bf2fb09d77eb3cef94).
Return statistics about ENV as a plist.
- :PAGE-SIZE: The size of a database page in bytes.
- :DEPTH: The height of the B-tree.
- :BRANCH-PAGES: The number of internal (non-leaf) pages.
- :LEAF-PAGES: The number of leaf pages.
- :OVERFLOW-PAGES: The number of overflow pages.
- :ENTRIES: The number of data items.
Wraps [mdb_env_stat()](http://www.lmdb.tech/doc/group__mdb.html#gaf881dca452050efbd434cd16e4bae255).
Return the value from DB associated with KEY and T as the second
value. If KEY is not found in DB, then NIL is returned. If DB
supports @DUPSORT, then the first value for KEY will be returned.
Retrieval of other values requires the use of @LMDB/CURSORS.
This function is called G3T instead of [GET][dislocated] to avoid
having to shadow CL:GET when importing the LMDB package. On the
other hand, importing the LMDB+ package, which has LMDB::GET
exported, requires some shadowing.
The LMDB+ package is like the LMDB package, but it has ‘#’LMDB:G3T‘
fbound to LMDB+:G3T so it probably needs shadowing to avoid conflict
with CL:GET:
“‘
(defpackage lmdb/test
(:shadow #:get)
(:use #:cl #:lmdb+))
“‘
Wraps [mdb_get()](http://www.lmdb.tech/doc/group__mdb.html#ga8bf10cd91d3f3a83a34d04ce6b07992d).
Return the value from DB associated with KEY and T as the second
value. If KEY is not found in DB, then NIL is returned. If DB
supports @DUPSORT, then the first value for KEY will be returned.
Retrieval of other values requires the use of @LMDB/CURSORS.
This function is called G3T instead of [GET][dislocated] to avoid
having to shadow CL:GET when importing the LMDB package. On the
other hand, importing the LMDB+ package, which has LMDB::GET
exported, requires some shadowing.
The LMDB+ package is like the LMDB package, but it has ‘#’LMDB:G3T‘
fbound to LMDB+:G3T so it probably needs shadowing to avoid conflict
with CL:GET:
“‘
(defpackage lmdb/test
(:shadow #:get)
(:use #:cl #:lmdb+))
“‘
Wraps [mdb_get()](http://www.lmdb.tech/doc/group__mdb.html#ga8bf10cd91d3f3a83a34d04ce6b07992d).
Open the database with NAME in the open environment ENV, and return
a DB object. If NAME is NIL, then the @LMDB/THE-UNNAMED-DATABASE is
opened.
If GET-DB is called with the same name multiple times, the returned
DB objects will be associated with the same database (although they
may not be EQ). The first time GET-DB is called with any given name
and environment, it must not be from an open transaction. This is
because GET-DB starts a transaction itself to comply with C lmdb’s
requirements on
[mdb_dbi_open()](http://www.lmdb.tech/doc/group__mdb.html#gac08cad5b096925642ca359a6d6f0562a) (see
@LMDB/SAFETY). Since dbi handles are cached within ENV, subsequent
calls do not involve ‘mdb_dbi_open()‘ and are thus permissible
within transactions.
CLASS designates the class which will instantiated. See *DB-CLASS*.
If IF-DOES-NOT-EXIST is :CREATE, then a new named database is
created. If IF-DOES-NOT-EXIST is :ERROR, then an error is signalled
if the database does not exists.
KEY-ENCODING and VALUE-ENCODING are both one of NIL, :UINT64,
:OCTETS or :UTF-8. KEY-ENCODING is set to :UINT64 when INTEGER-KEY
is true. VALUE-ENCODING is set to :UINT64 when INTEGER-DUP is true.
Note that changing the encoding does *not* reencode already existing
data. See @LMDB/ENCODINGS for the full semantics.
GET-DB may be called more than once with the same NAME and ENV, and
the returned DB objects will have the same underlying C lmdb
database, but they may have different KEY-ENCODING and
VALUE-ENCODING.
The following flags are for database creation, they do not have any
effect in subsequent calls (except for the
@LMDB/THE-UNNAMED-DATABASE).
- INTEGER-KEY: Keys in the database are C ‘unsigned‘ or ‘size_t‘
integers encoded in native byte order. Keys must all be either
‘unsigned‘ or ‘size_t‘, they cannot be mixed in a single database.
- REVERSE-KEY: Keys are strings to be compared in reverse order,
from the end of the strings to the beginning. By default, keys are
treated as strings and compared from beginning to end.
- DUPSORT: Duplicate keys may be used in the database (or, from
another perspective, keys may have multiple values, stored in
sorted order). By default, keys must be unique and may have only a
single value. Also, see @DUPSORT.
- INTEGER-DUP: This option specifies that duplicate data items are
binary integers, similarly to INTEGER-KEY. Only matters if
DUPSORT.
- REVERSE-DUP: This option specifies that duplicate data items
should be compared as strings in reverse order. Only matters if
DUPSORT.
- DUPFIXED: This flag may only be used in combination DUPSORT. When
true, data items for this database must all be the same size,
which allows further optimizations in storage and retrieval.
Currently, the wrapper functions that could take advantage of
this (e.g. PUT, CURSOR-PUT, CURSOR-NEXT and CURSOR-VALUE), do not.
No function to close a database (an equivalent to
[mdb_dbi_close()](http://www.lmdb.tech/doc/group__mdb.html#ga52dd98d0c542378370cd6b712ff961b5))
is provided due to subtle races and corruption it could cause when
an ‘MDB_dbi‘ (unsigned integer, similar to an fd) is assigned by a
subsequent open to another named database.
Wraps [mdb_dbi_open()](http://www.lmdb.tech/doc/group__mdb.html#gac08cad5b096925642ca359a6d6f0562a).
A thin wrapper around DO-DB-DUP, this function returns all values associated with KEY in DB as a list. If FROM-END, then the first element of the list is the largest value.
Return a string representing the version of C lmdb based on which the CFFI bindings were created. The version string has the same format as LMDB-FOREIGN-VERSION.
Return the version of the C lmdb library as a string like ‘0.9.26‘.
Wraps [mdb_version()](http://www.lmdb.tech/doc/group__mdb.html#ga0e5d7298fc39b3c187fffbe30264c968).
A utility function provided for writing *KEY-DECODER* and *VALUE-DECODER* functions. It returns a Lisp octet vector that holds the same bytes as MDB-VAL.
Like OCTETS-TO-STRING, but suitable as a *KEY-DECODER* or *VALUE-DECODER*.
Like OCTETS-TO-UINT64, but suitable for *KEY-DECODER* or *VALUE-DECODER* that decodes unsigned 64 bit integers in native byte order. This function is called automatically when the encoding is known to require it (see GET-DB’s INTEGER-KEY, :VALUE-ENCODING, etc).
The inverse of STRING-TO-OCTETS. Use MDB-VAL-TO-STRING as a *KEY-DECODER* or *VALUE-DECODER*.
The inverse of UINT64-TO-OCTETS. Use MDB-VAL-TO-UINT64 as a *KEY-DECODER* or *VALUE-DECODER*.
Create an ENV object through which the LMDB environment can be
accessed and open it. To prevent corruption, an error is signalled
if the same data file is opened multiple times. However, the checks
performed do not work on remote filesystems (see ENV-PATH).
LMDB-ERROR is signalled if opening the environment fails for any
other reason.
Unless explicitly noted, none of the arguments persist (i.e. they
are not saved in the data file).
PATH is the filesystem location of the environment files (see SUBDIR
below for more). Do not use LMDB data files on remote filesystems,
even between processes on the same host. This breaks ‘flock()‘ on
some OSes, possibly memory map sync, and certainly sync between
programs on different hosts.
IF-DOES-NOT-EXIST determines what happens if ENV-PATH does not
exists:
- :ERROR: An error is signalled.
- :CREATE: A new memory-mapped file is created ensuring that all
containing directories exist.
- ‘NIL‘: Return NIL without doing anything.
See CLOSE-ENV for the description of SYNCHRONIZED.
- MAX-DBS: The maximum number of named databases in the environment.
Currently a moderate number is cheap, but a huge number gets
expensive: 7-120 words per transaction, and every GET-DB does a
linear search of the opened database.
- MAP-SIZE: Specifies the size of the data file in bytes. The new
size takes effect immediately for the current process, but will
not be persisted to any others until a write transaction has been
committed by the current process. Also, only map size increases
are persisted into the environment. If the map size is increased
by another process, and data has grown beyond the range of the
current mapsize, starting a new transaction (see WITH-TXN) will
signal LMDB-MAP-RESIZED-ERROR. If zero is specified for MAP-SIZE,
then the persisted size is used from the data file. Also see
LMDB-MAP-FULL-ERROR.
- MODE: Unix file mode for files created. The default is ‘#o664‘.
Has no effect when opening an existing environment.
The rest of the arguments correspond to LMDB environment flags and
are available in the plist ENV-FLAGS.
- SUBDIR: If SUBDIR, then the path is a directory which holds the
‘data.mdb‘ and the ‘lock.mdb‘ files. If SUBDIR is NIL, the path
is the filename of the data file and the lock file has the same
name plus a ‘-lock‘ suffix.
- SYNC: If NIL, don’t ‘fsync‘ after commit. This optimization means
a system crash can corrupt the database or lose the last
transactions if buffers are not yet flushed to disk. The risk is
governed by how often the system flushes dirty buffers to disk and
how often SYNC-ENV is called. However, if the filesystem preserves
write order (very few do) and the WRITE-MAP (currently
unsupported) flag is not used, transactions exhibit
ACI (atomicity, consistency, isolation) properties and only lose
D (durability). I.e. database integrity is maintained, but a
system crash may undo the final transactions.
- META-SYNC: If NIL, flush system buffers to disk only once per
transaction, but omit the metadata flush. Defer that until the
system flushes files to disk, the next commit of a non-read-only
transaction or SYNC-ENV. This optimization maintains database
integrity, but a system crash may undo the last committed
transaction. I.e. it preserves the ACI (atomicity, consistency,
isolation) but not D (durability) database property.
- READ-ONLY: Map the data file in read-only mode. It is an error to
try to modify anything in it.
- TLS: Setting it to NIL allows each OS thread to have multiple
read-only transactions (see WITH-TXN’s IGNORE-PARENT argument). It
also allows and transactions not to be tied to a single thread,
but that’s quite dangerous, see @LMDB/SAFETY.
- READ-AHEAD: Turn off readahead as in ‘madvise(MADV_RANDOM)‘. Most
operating systems perform read-ahead on read requests by default.
This option turns it off if the OS supports it. Turning it off may
help random read performance when the DB is larger than RAM and
system RAM is full. This option is not implemented on Windows.
- LOCK: Data corruption lurks here. If NIL, don’t do any locking. If
concurrent access is anticipated, the caller must manage all
concurrency itself. For proper operation the caller must enforce
single-writer semantics, and must ensure that no readers are using
old transactions while a writer is active. The simplest approach
is to use an exclusive lock so that no readers may be active at
all when a writer begins.
- MEM-INIT: If NIL, don’t initialize ‘malloc‘ed memory before
writing to unused spaces in the data file. By default, memory for
pages written to the data file is obtained using ‘malloc‘. While
these pages may be reused in subsequent transactions, freshly
‘malloc‘ed pages will be initialized to zeroes before use. This
avoids persisting leftover data from other code (that used the
heap and subsequently freed the memory) into the data file. Note
that many other system libraries may allocate and free memory from
the heap for arbitrary uses. E.g., stdio may use the heap for file
I/O buffers. This initialization step has a modest performance
cost so some applications may want to disable it using this flag.
This option can be a problem for applications which handle
sensitive data like passwords, and it makes memory checkers like
Valgrind noisy. This flag is not needed with WRITE-MAP, which
writes directly to the mmap instead of using malloc for pages.
- FIXED-MAP (experimental): This flag must be specified when
creating the environment and is stored persistently in the data
file. If successful, the memory map will always reside at the same
virtual address and pointers used to reference data items in the
database will be constant across multiple invocations. This option
may not always work, depending on how the operating system has
allocated memory to shared libraries and other uses.
Unsupported flags (an error is signalled if they are changed from
their default values):
- WRITE-MAP: Use a writable memory map unless READ-ONLY is set. This
is faster and uses fewer mallocs, but loses protection from
application bugs like wild pointer writes and other bad updates
into the database. Incompatible with nested transactions. This may
be slightly faster for DBs that fit entirely in RAM, but is slower
for DBs larger than RAM. Do not mix processes with and without
WRITE-MAP on the same environment. This can defeat
durability (SYNC-ENV, etc).
- MAP-ASYNC: When using WRITE-MAP, use asynchronous flushes to disk.
As with SYNC NIL, a system crash can then corrupt the database or
lose the last transactions. Calling #sync ensures on-disk database
integrity until next commit.
Open environments have a finalizer attached to them that takes care
of freeing foreign resources. Thus, the common idiom:
“‘
(setq *env* (open-env "some-path"))
“‘
is okay for development, too. No need to always do WITH-ENV,
which does not mesh with threads anyway.
Wraps [mdb_env_create()](http://www.lmdb.tech/doc/group__mdb.html#gaad6be3d8dcd4ea01f8df436f41d158d4) and [mdb_env_open()](http://www.lmdb.tech/doc/group__mdb.html#ga32a193c6bf4d7d5c5d579e71f22e9340).
See if ENV is open, i.e. OPEN-ENV has been called on it without a corresponding CLOSE-ENV.
See if there is an active transaction and it is open, i.e. COMMIT-TXN or ABORT-TXN have not been called on it. Also, RESET-TXN without a corresponding RENEW-TXN closes the transaction.
Add a KEY, VALUE pair to DB within TXN (which must support writes).
Returns T on success.
- OVERWRITE: If NIL, signal LMDB-KEY-EXISTS-ERROR if KEY already
appears in DB.
- DUPDATA: If NIL, signal LMDB-KEY-EXISTS-ERROR if the KEY, VALUE
pair already appears in DB. Has no effect if DB doesn’t have
DUPSORT.
- APPEND: Append the KEY, VALUE pair to the end of DB instead of
finding KEY’s location in the B+ tree by performing comparisons.
The client effectively promises that keys are inserted in sort
order, which allows for fast bulk loading. If the promise is
broken, a LMDB-KEY-EXISTS-ERROR is signalled.
- APPEND-DUP: The client promises that duplicate values are inserted
in sort order. If the promise is broken, a LMDB-KEY-EXISTS-ERROR
is signalled.
- If KEY-EXISTS-ERROR-P is NIL, then instead of signalling
LMDB-KEY-EXISTS-ERROR return NIL.
May signal LMDB-MAP-FULL-ERROR, LMDB-TXN-FULL-ERROR,
LMDB-TXN-READ-ONLY-ERROR.
Wraps [mdb_put()](http://www.lmdb.tech/doc/group__mdb.html#ga4fa8573d9236d54687c61827ebf8cac0).
Renew TXN that was reset by RESET-TXN. This acquires a new reader
lock that had been released by RESET-TXN. After renewal, it is as if
TXN had just been started.
Wraps [mdb_txn_renew()](http://www.lmdb.tech/doc/group__mdb.html#ga6c6f917959517ede1c504cf7c720ce6d).
Abort the open, read-only TXN, release the reference to the
historical version of the environment, but make it faster to start
another read-only transaction with RENEW-TXN. This is accomplished
by not deallocating some data structures, and keeping the slot in
the reader table. Cursors opened within the transaction must not be
used again, except if renewed (see RENEW-CURSOR). If TXN is an open,
read-only transaction, this function always succeeds.
Wraps [mdb_txn_reset()](http://www.lmdb.tech/doc/group__mdb.html#ga02b06706f8a66249769503c4e88c56cd).
Convert STRING to OCTETS by encoding it as UTF-8 with null termination. Suitable as a *KEY-ENCODER* or *VALUE-ENCODER*.
Flush the data buffers to disk as in calling ‘fsync()‘. When ENV
had been opened with :SYNC NIL or :META-SYNC NIL, this may be handy
to force flushing the OS buffers to disk, which avoids potential
durability and integrity issues.
Wraps [mdb_env_sync()](http://www.lmdb.tech/doc/group__mdb.html#ga85e61f05aa68b520cc6c3b981dba5037).
The ID of TXN. IDs are integers incrementing from 1. For a read-only transaction, this corresponds to the snapshot being read; concurrent readers will frequently have the same transaction ID. Only committed write transactions increment the ID. If a transaction aborts, the ID may be re-used by the next writer.
Convert an ‘(UNSIGNED-BYTE 64)‘ to OCTETS of length 8 taking the native byte order representation of N. Suitable as a *KEY-ENCODER* or *VALUE-ENCODER*.
The specified DBI was changed unexpectedly.
lmdb
.
Invalid reuse of reader locktable slot. May be signalled by WITH-TXN.
lmdb
.
Transaction must abort, has a child, or is invalid.
Signalled, for example, when a read-only transaction is nested in a
read-write transaction, or when a cursor is used whose transaction
has been closed (committed, aborted, or reset).
lmdb
.
Unsupported size of key/DB name/data, or wrong
DUPFIXED, INTEGER-KEY or INTEGER-DUP. See ENV-MAX-KEY-SIZE.
lmdb
.
Located page was wrong type.
lmdb
.
Cursor stack too deep - internal error.
lmdb
.
Cursor was accessed from a thread other than the
one in which it was created. Since the foreign cursor object’s
lifetime is tied to the dynamic extent of its WITH-CURSOR, this
might mean accessing garbage in foreign memory with unpredictable
consequences.
lmdb
.
Cursor was not initialized. Position the cursor at
a key-value pair with a function like CURSOR-FIRST or
CURSOR-SET-KEY. Signalled when some functions return the C error
code ‘EINVAL‘.
lmdb
.
ENV-MAX-DBS reached. Reopen the environment with a higher :MAX-DBS.
lmdb
.
Base class for normal, recoverable LMDB errors.
lmdb
.
error
.
lmdb-serious-condition
.
lmdb-bad-dbi-error
.
lmdb-bad-rslot-error
.
lmdb-bad-txn-error
.
lmdb-bad-valsize-error
.
lmdb-cursor-thread-error
.
lmdb-cursor-uninitialized-error
.
lmdb-dbs-full-error
.
lmdb-illegal-access-to-parent-txn-error
.
lmdb-incompatible-error
.
lmdb-key-exists-error
.
lmdb-map-full-error
.
lmdb-map-resized-error
.
lmdb-not-found-error
.
lmdb-readers-full-error
.
lmdb-txn-full-error
.
lmdb-txn-read-only-error
.
lmdb-version-mismatch-error
.
A parent transaction and its cursors may not
issue any other operations than COMMIT-TXN and ABORT-TXN while it
has active child transactions. In LMDB, @LMDB/BASIC-OPERATIONS are
always executed in the @ACTIVE-TRANSACTION, but @LMDB/CURSORS can
refer to the parent transaction:
“‘
(with-temporary-env (*env*)
(let ((db (get-db "db")))
(with-txn (:write t)
(put db #(1) #(1))
(with-cursor (cursor db)
(with-txn (:write t)
(assert-error lmdb-illegal-access-to-parent-txn-error
(cursor-set-key #(1) cursor)))))))
“‘
lmdb
.
Operation and DB incompatible, or DB type changed.
This can mean:
- The operation expects a @DUPSORT or DUPFIXED database.
- Opening a named DB when the unnamed DB has DUPSORT or INTEGER-KEY.
- Accessing a data record as a database, or vice versa.
- The database was dropped and recreated with different flags.
lmdb
.
File is not a valid LMDB file.
lmdb
.
Key-value pair already exists. Signalled by PUT and CURSOR-PUT.
lmdb
.
ENV-MAP-SIZE reached. Reopen the environment with a larger :MAP-SIZE.
lmdb
.
Data file contents grew beyond ENV-MAP-SIZE. This
can happen if another OS process using the same environment path set
a larger map size than this process did.
lmdb
.
Key-value pair does not exist. All functions (G3T, CURSOR-NEXT, ...) should return NIL instead of signalling this error. If it is signalled, that’s a bug.
lmdb
.
Page has not enough space - internal error.
lmdb
.
Requested page not found - this usually indicates corruption.
lmdb
.
Update of meta page failed or environment had fatal error.
lmdb
.
ENV-MAX-READERS reached. Reopen the environment with a higher :MAX-READERS.
lmdb
.
The base class of all LMDB conditions. Conditions
that are LMDB-SERIOUS-CONDITIONs, but not LMDB-ERRORs are corruption
and internal errors, which are hard to recover from.
lmdb
.
serious-condition
.
:error-code
This slot is read-only.
:control-string
This slot is read-only.
:format-args
This slot is read-only.
TXN has too many dirty pages. This condition is
expected to occur only when using nested read-write transactions or
operations multiple items (currently not supported by this
wrapper).
lmdb
.
Attempt was made to write in a read-only
transaction. Signalled when some functions return the C error code
‘EACCESS‘.
lmdb
.
Environment version mismatch.
lmdb
.
A database in an environment (class ENV). Always to be created by GET-DB.
lmdb
.
The name of the database.
string
:name
This slot is read-only.
The ENCODING that was passed as KEY-ENCODING to GET-DB.
lmdb:encoding
:key-encoding
This slot is read-only.
The ENCODING that was passed as VALUE-ENCODING to GET-DB.
lmdb:encoding
:value-encoding
This slot is read-only.
An environment object through which a memory-mapped
data file can be accessed. Always to be created by OPEN-ENV.
lmdb
.
The location of the memory-mapped file and the environment lock file.
:path
This slot is read-only.
The maximum number of named databases in the
environment. Currently a moderate number is cheap, but a huge
number gets expensive: 7-120 words per transaction, and every
GET-DB does a linear search of the opened database.
integer
:max-dbs
This slot is read-only.
The maximum number of threads/reader slots. See
the documentation of the [reader lock
table](http://lmdb.tech/doc/group__readers.html) for more.
integer
:max-readers
This slot is read-only.
Specifies the size of the data file in bytes.
integer
:map-size
This slot is read-only.
A plist of the options as captured by OPEN-ENV. For example, ‘(:FIXED-MAP NIL :SUBDIR T ...)‘.
list
:flags
This slot is read-only.
(bordeaux-threads:make-lock "db-lock")
This slot is read-only.
(make-hash-table :test (function equal))
This slot is read-only.
:n-txns
This slot is read-only.
foreign-struct-type
.
translatable-foreign-type
.
foreign-struct-type
.
translatable-foreign-type
.
foreign-struct-type
.
translatable-foreign-type
.
The following values are supported:
- :UINT64: Data to be encoded must be of type ‘(UNSIGNED-BYTE 64)‘,
which is then encoded as an 8 byte array in _native_ byte order
with UINT64-TO-OCTETS. The reverse transformation takes place when
returning values. This is the encoding used for INTEGER-KEY and
INTEGER-DUP DBs.
- :OCTETS: Note the plural. Data to be encoded (e.g. KEY argument of
G3T) must be a 1D byte array. If its element type
is ‘(UNSIGNED-BYTE 8)‘, then the data can be passed to the foreign
code more efficiently, but declaring the element type is not
required. For example, [VECTOR][type]s can be used as long as the
actual elements are of type ‘(UNSIGNED-BYTE 8)‘. Foreign byte
arrays to be decoded (e.g. the value returned by G3T) are returned
as OCTETS.
- :UTF-8: Data to be encoded must be a string, which is converted to
octets by TRIVIAL-UTF-8. Null-terminated. Foreign byte arrays are
decoded the same way.
- NIL: Data is encoded using the default encoding according to its
Lisp type: strings as :UTF-8, vectors as :OCTETS, ‘(UNSIGNED-BYTE
64)‘ as :UINT64. Decoding is always performed as :OCTETS.
- A [CONS][type]: Data is encoded by the function in the CAR of the cons and decoded by the function in the CDR. For example, :UINT64 is equivalent to ‘(CONS #’UINT64-TO-OCTETS #’MDB-VAL-TO-UINT64)‘.
A 1D SIMPLE-ARRAY of ‘(UNSIGNED-BYTE 8)‘.
CL:SHADOW the symbol GET in PACKAGE and make it an alias for LMDB:G3T. Do this at compile time if at the top level.
lmdb
.
lmdb
.
lmdb-serious-condition
)) ¶lmdb
.
lmdb-serious-condition
)) ¶lmdb
.
lmdb-serious-condition
)) ¶Jump to: | %
(
A C D E F G I L M O P R S T U V W |
---|
Jump to: | %
(
A C D E F G I L M O P R S T U V W |
---|
Jump to: | %
*
+
@
C D E F K M N P S T V |
---|
Jump to: | %
*
+
@
C D E F K M N P S T V |
---|
Jump to: | C D E F L M O P S T V |
---|
Jump to: | C D E F L M O P S T V |
---|