v2.0.0
LMDB v2.0.0
Revival of LMDB.jl, fixing many issues and adding a new mid-level API for more direct access to LMDB's features (i.e., where the Dict doesn't suffice, but without having to drop down to the C API).
Breaking changes:
- The minimum Julia version is now 1.10.
- The factory functions
create(),environment(path),start(env),open(env, path),open(txn),open(txn, dbi)have been replaced by constructors:LMDB.Environment(path; mapsize, maxreaders, maxdbs, flags, mode),LMDB.Transaction(env; flags, parent),LMDB.Database(txn, name; flags),LMDB.Cursor(txn, dbi). - The
DBIstruct was renamed toDatabase. - Only
LMDBDictandLMDBErrorare exported. Everything else moved to @public, so the wrapper types and operations are reached asLMDB.Environment,LMDB.Transaction,LMDB.Database,LMDB.Cursor,LMDB.set!,LMDB.sync,LMDB.info,LMDB.seek!, etc. - The whole 1.x cursor iteration surface is gone:
LMDBIterator,ReturnKeys,ReturnValues,ReturnBoth,ReturnValueSize,DirectoryLister,Base.iterate(cur, K, V),keys(cur, T; prefix),values(cur, T; prefix), andget(cur, key, T, op::MDB_cursor_op). Replaced by either iteration overLMDBDict(which is now <:AbstractDict) or, at the cursor level, explicit positioning withLMDB.seek!/LMDB.seek_range!/LMDB.next!/LMDB.prev!/ the_dup/_nodup variants plusLMDB.key(cur, K)/LMDB.value(cur, V)/LMDB.item(cur, K, V). For bulk traversal, useLMDB.walk(f, cur; from). tryget(txn, dbi, key, T)is replaced byLMDB.get(txn, dbi, key, T, nothing), which is the canonicalBase.get(d, k, default)shape. The throwing formLMDB.get(txn, dbi, key, T)and the new default-formLMDB.get(txn, dbi, key, T, default)are the two read primitives.- The custom typed-decode extension point
_mbd_unpack(T, ::MDB_val)is gone. OverrideBase.read(io::IO, ::Type{T})instead. Base.keys(d::LMDBDict; prefix)andBase.values(d::LMDBDict; prefix)no longer return a collected Vector; they now return the standardKeySet/ValueIteratorviews fromAbstractDict. For prefix-scoped collected results, useLMDB.scan_keys(d; prefix),LMDB.scan_values(d; prefix), orLMDB.scan(d; prefix)for pairs.Base.empty(d::LMDBDict)andBase.copy(d::LMDBDict)now throwArgumentError: anLMDBDictneeds an on-disk directory, so there's no path-less zero-argument form. UseDict(d)for an in-memory snapshot orBase.copy(d.env, path)for an on-disk clone.info(env)previously returned anMDB_envinfoC struct withme_-prefixed fields. It now returns aNamedTuplewithmapaddr,mapsize,last_pgno,last_txnid,maxreaders,numreaders.put!(txn, dbi, key, val)returns nothing instead of aCintstatus.delete!(txn, dbi, key)returnsBool(true if removed, false ifMDB_NOTFOUND) instead of throwing on missing. The optional val argument no longer has aC_NULLdefault; usedelete!(txn, dbi, key, val)forDUPSORT-specific dup removal.LMDB.LibLMDBsubmodule is gone. C bindings live directly inLMDBnow, reachable asLMDB.mdb_env_open,LMDB.MDB_val,LMDB.MDB_NOTFOUND, etc.env[:Unknown]andenv[:Unknown] = vnow throwArgumentErrorinstead of warning and returning a meaningless zero.
For an example, what looked like this in 1.0:
env = create()
env[:MapSize] = 1 << 30
open(env, "/tmp/db")
start(env) do txn
dbi = open(txn)
put!(txn, dbi, "k", "v")
v = tryget(txn, dbi, "k", String) # → Union{String,Nothing}
end
close(env)... now looks like:
LMDB.Environment("/tmp/db"; mapsize = 1 << 30) do env
LMDB.Transaction(env) do txn
LMDB.Database(txn) do dbi
put!(txn, dbi, "k", "v")
v = LMDB.get(txn, dbi, "k", String, nothing)
end
end
endMerged pull requests:
- Bump to Julia 1.10 and update CI. (#49) (@maleadt)
- Fix correctness bugs (#50) (@maleadt)
- Modernize Clang.jl-generated bindings. (#51) (@maleadt)
- Improve wrappers (#52) (@maleadt)
- Add a high-level API (#53) (@maleadt)
- Improve LMDBDict (#54) (@maleadt)
- Switch typed-read extension point to Base.read(::MDBValueIO, T). (#55) (@maleadt)
- Extend documentation (#56) (@maleadt)
- Improve tests (#57) (@maleadt)
- Get rid of some LLMisms. (#58) (@maleadt)
- Improve test coverage (#59) (@maleadt)
- Audit exports. (#60) (@maleadt)
- NFC clean-ups. (#61) (@maleadt)
- Bump codecov/codecov-action from 5 to 6 (#63) (@dependabot[bot])
- Bump julia-actions/cache from 2 to 3 (#64) (@dependabot[bot])
- Bump actions/checkout from 4 to 6 (#65) (@dependabot[bot])
- Bump JLL version. (#66) (@maleadt)
- Improvements to new Julia API (#67) (@maleadt)
Closed issues: