Skip to content

Commit 2a9bd84

Browse files
committed
Rename DBI to Database, qualify demoted names in tests.
`Database` reads better than the C-flavoured `DBI`. The struct, all its method signatures, and every prose mention switch over. The underlying `MDB_dbi` Cuint type (the C ABI) is unchanged; only the Julia wrapper renames. While here, switch the tests from bare names to the `LMDB.X` qualification that user code actually sees after the recent export demotion. `LMDBDict` / `LMDBError` stay unprefixed (still exported); `LMDB.Environment`, `LMDB.Transaction`, `LMDB.Database`, `LMDB.Cursor`, and the env operations (`LMDB.set!`, `LMDB.unset!`, `LMDB.sync`, `LMDB.info`, `LMDB.reader_check`, `LMDB.reader_list`) gain the prefix. The earlier `using LMDB: ...` hack in runtests.jl is gone.
1 parent 4ec9722 commit 2a9bd84

21 files changed

Lines changed: 209 additions & 216 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ LMDB.jl exposes the same database through three surfaces:
2222
`AbstractDict{K,V}` over a single LMDB file. Standard library
2323
machinery (`merge!`, `filter!`, `pairs`, iteration, …) works out
2424
of the box. Reach for this when you want a persistent `Dict`.
25-
- Julia wrappers: `Environment`, `Transaction`, `DBI`, `Cursor`.
25+
- Julia wrappers: `Environment`, `Transaction`, `Database`, `Cursor`.
2626
Julia-shaped wrappers around handles, transactions, and cursors,
2727
with finalizers, `do`-block forms, and so on. Use these when you
2828
want explicit transactions.

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LMDB.jl exposes the same database through three surfaces:
1818
| Surface | What it offers | When to use |
1919
|---------|----------------|-------------|
2020
| High-level interface | `LMDBDict <: AbstractDict{K,V}` | When you want a persistent `Dict`. |
21-
| Julia wrappers | `Environment`, `Transaction`, `DBI`, `Cursor` | When you want explicit transactions and cursors with Julia-shaped wrappers. |
21+
| Julia wrappers | `Environment`, `Transaction`, `Database`, `Cursor` | When you want explicit transactions and cursors with Julia-shaped wrappers. |
2222
| C API | `LMDB.mdb_*`, `LMDB.MDB_*` | Raw `ccall` bindings and status-code constants, for custom data layouts or when you want to skip allocations on hot paths. |
2323

2424
`MDBValue`, `MDBArg`, and the [`MDBValueIO`](@ref LMDB.MDBValueIO)

docs/src/lib/cursors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
CurrentModule = LMDB
55
```
66

7-
A `Cursor` is a positioned iterator over the entries in a `DBI`. Cursors
7+
A `Cursor` is a positioned iterator over the entries in a `Database`. Cursors
88
are bound to a transaction. Closing the txn invalidates the cursor.
99

1010
## Construction
1111

1212
```@docs
1313
Cursor
14-
Cursor(::Transaction, ::DBI)
14+
Cursor(::Transaction, ::Database)
1515
Base.close(::Cursor)
1616
Base.isopen(::Cursor)
1717
renew(::Transaction, ::Cursor)

docs/src/lib/databases.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
# [Databases](@id API-DBI)
1+
# [Databases](@id API-Database)
22

33
```@meta
44
CurrentModule = LMDB
55
```
66

7-
A `DBI` (database identifier) is a handle to one B-tree inside an
7+
A `Database` (database identifier) is a handle to one B-tree inside an
88
environment. By default an env has a single anonymous database (the
9-
"main DB"); pass `maxdbs > 0` to `Environment` and a name to the `DBI`
9+
"main DB"); pass `maxdbs > 0` to `Environment` and a name to the `Database`
1010
constructor to work with multiple named sub-databases.
1111

1212
## Construction
1313

1414
```@docs
15-
DBI
16-
DBI(::Transaction, ::AbstractString)
17-
Base.close(::Environment, ::DBI)
18-
Base.isopen(::DBI)
15+
Database
16+
Database(::Transaction, ::AbstractString)
17+
Base.close(::Environment, ::Database)
18+
Base.isopen(::Database)
1919
flags
2020
drop
21-
Base.stat(::Transaction, ::DBI)
21+
Base.stat(::Transaction, ::Database)
2222
```
2323

2424
## Reads
2525

2626
```@docs
27-
Base.get(::Transaction, ::DBI, ::Any, ::Type{T}) where T
28-
Base.get(::Transaction, ::DBI, ::Any, ::Type{T}, ::Any) where T
27+
Base.get(::Transaction, ::Database, ::Any, ::Type{T}) where T
28+
Base.get(::Transaction, ::Database, ::Any, ::Type{T}, ::Any) where T
2929
```
3030

3131
`get(txn, dbi, key, T, default)` falls back to `default` if `key` is
@@ -34,11 +34,11 @@ missing, matching `Base.get(dict, key, default)`.
3434
## Writes
3535

3636
```@docs
37-
Base.put!(::Transaction, ::DBI, ::Any, ::Any)
37+
Base.put!(::Transaction, ::Database, ::Any, ::Any)
3838
put_reserved!
39-
Base.delete!(::Transaction, ::DBI, ::Any)
40-
Base.replace!(::Transaction, ::DBI, ::Any, ::Any)
41-
Base.pop!(::Transaction, ::DBI, ::Any, ::Type)
39+
Base.delete!(::Transaction, ::Database, ::Any)
40+
Base.replace!(::Transaction, ::Database, ::Any, ::Any)
41+
Base.pop!(::Transaction, ::Database, ::Any, ::Type)
4242
```
4343

4444
## Write flags

docs/src/lib/dict.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Everything `AbstractDict` derives (`merge!`, `merge`, `mergewith!`,
3232

3333
## Lifecycle
3434

35-
`close(::LMDBDict)` closes the underlying env (and the default DBI).
35+
`close(::LMDBDict)` closes the underlying env (and the default Database).
3636
Idempotent, and also called from the finalizer.
3737

3838
## Prefix-scan helpers

docs/src/lib/lowlevel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ mdb_txn_reset
107107
mdb_txn_renew
108108
```
109109

110-
### Database (DBI)
110+
### Database (Database)
111111

112112
```julia
113113
mdb_dbi_open

docs/src/man/cursors.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
CurrentModule = LMDB
55
```
66

7-
A `Cursor` is a positioned iterator over a `DBI`. Use it for ordered
7+
A `Cursor` is a positioned iterator over a `Database`. Use it for ordered
88
scans, range queries, or to amortise the per-lookup overhead of
99
`mdb_get` across many keys.
1010

1111
## Opening a cursor
1212

1313
```julia
1414
Transaction(env; flags = LMDB.MDB_RDONLY) do txn
15-
DBI(txn) do dbi
15+
Database(txn) do dbi
1616
Cursor(txn, dbi) do cur
1717
# use cur
1818
end
@@ -67,7 +67,7 @@ A typical pattern for "all keys with a given prefix":
6767
```julia
6868
prefix = "users/"
6969
Transaction(env; flags = LMDB.MDB_RDONLY) do txn
70-
DBI(txn) do dbi
70+
Database(txn) do dbi
7171
Cursor(txn, dbi) do cur
7272
k = seek_range!(cur, prefix, String)
7373
while k !== nothing && startswith(k, prefix)

docs/src/man/databases.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
CurrentModule = LMDB
55
```
66

7-
A `DBI` is a handle to one B-tree inside an environment. By default an
7+
A `Database` is a handle to one B-tree inside an environment. By default an
88
env has a single anonymous database (the "main DB"); pass `maxdbs > 0`
99
to `Environment` to support multiple named sub-databases.
1010

11-
## Opening a DBI
11+
## Opening a Database
1212

1313
```julia
14-
dbi = DBI(txn) # main (unnamed) DB
15-
dbi = DBI(txn, "users") # named sub-DB; needs maxdbs >= 1
16-
dbi = DBI(txn, "edges"; flags = LMDB.MDB_CREATE | LMDB.MDB_DUPSORT)
14+
dbi = Database(txn) # main (unnamed) DB
15+
dbi = Database(txn, "users") # named sub-DB; needs maxdbs >= 1
16+
dbi = Database(txn, "edges"; flags = LMDB.MDB_CREATE | LMDB.MDB_DUPSORT)
1717
```
1818

19-
The do-block form closes the DBI on the way out:
19+
The do-block form closes the Database on the way out:
2020

2121
```julia
22-
DBI(txn, "users") do dbi
22+
Database(txn, "users") do dbi
2323
put!(txn, dbi, "1", "Ada")
2424
end
2525
```
2626

27-
In practice you'll rarely *want* to close a DBI handle explicitly. The
27+
In practice you'll rarely *want* to close a Database handle explicitly. The
2828
env owns it, and `mdb_dbi_close` is documented as rarely useful. The
29-
env's finalizer cascades through any open DBI handles.
29+
env's finalizer cascades through any open Database handles.
3030

31-
## DBI flags
31+
## Database flags
3232

3333
`flags` accepts a bitwise-or of:
3434

@@ -86,7 +86,7 @@ Useful write flags:
8686
```julia
8787
# Bulk import in sorted order:
8888
Transaction(env) do txn
89-
DBI(txn) do dbi
89+
Database(txn) do dbi
9090
for (k, v) in sorted_pairs
9191
put!(txn, dbi, k, v; flags = LMDB.MDB_APPEND)
9292
end

docs/src/man/dict.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CurrentModule = LMDB
55
```
66

77
`LMDBDict{K,V}` is a persistent `AbstractDict{K,V}` backed by a single
8-
LMDB environment plus the default DBI. Open it, treat it like a `Dict`,
8+
LMDB environment plus the default Database. Open it, treat it like a `Dict`,
99
close it.
1010

1111
## Construction

docs/src/man/dupsort.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ values" patterns.
1313
```julia
1414
env = Environment("/tmp/edges"; mapsize = 1 << 30, maxdbs = 1)
1515
Transaction(env) do txn
16-
dbi = DBI(txn, "edges"; flags = LMDB.MDB_CREATE | LMDB.MDB_DUPSORT)
16+
dbi = Database(txn, "edges"; flags = LMDB.MDB_CREATE | LMDB.MDB_DUPSORT)
1717
put!(txn, dbi, "a", "b")
1818
put!(txn, dbi, "a", "c")
1919
put!(txn, dbi, "a", "d")

0 commit comments

Comments
 (0)