Skip to content

Commit f1e13cf

Browse files
authored
Get rid of some LLMisms. (#58)
1 parent df59a66 commit f1e13cf

23 files changed

Lines changed: 149 additions & 151 deletions

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaDatabases.github.io/LMDB.jl/dev)
77

88
Julia bindings for [LMDB](http://www.lmdb.tech/doc/), the Lightning
9-
Memory-Mapped Database: An embedded, memory-mapped, ACID key-value store
10-
developed by Symas for OpenLDAP. Small, fast, persisted to disk, and reads at
11-
near in-memory speeds.
9+
Memory-Mapped Database. LMDB is an embedded, memory-mapped, ACID key-value
10+
store developed by Symas for OpenLDAP. It persists to disk while reading
11+
at near in-memory speeds.
1212

1313
```julia
1414
using Pkg; Pkg.add("LMDB")
@@ -18,15 +18,15 @@ using Pkg; Pkg.add("LMDB")
1818

1919
LMDB.jl exposes the same database through three surfaces:
2020

21-
- **High-level interface**: `LMDBDict <: AbstractDict`, an
21+
- High-level interface: `LMDBDict <: AbstractDict`, an
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`, `DBI`, `Cursor`.
2626
Julia-shaped wrappers around handles, transactions, and cursors,
27-
with finalizers, `do`-block forms, etc. Use this when you want
28-
explicit transactions.
29-
- **C API**: `LMDB.mdb_*` and `LMDB.MDB_*`. Raw `ccall` bindings and
27+
with finalizers, `do`-block forms, and so on. Use these when you
28+
want explicit transactions.
29+
- C API: `LMDB.mdb_*` and `LMDB.MDB_*`. Raw `ccall` bindings and
3030
status-code constants. Use this when the Julia wrappers don't expose
3131
a particular API or you want to inspect status codes directly.
3232

@@ -86,8 +86,8 @@ end
8686

8787
The package decodes `String`, `Vector{T}` for any bitstype `T`, and the
8888
primitive numeric types out of the box. To plug in a custom representation,
89-
define a `Base.read(io::IO, ::Type{T})` method; it will be picked up by `tryget`
90-
/ `get` / `walk(f, cur, K, V)` and the cursor accessors `key`/`value`/`item`.
89+
define a `Base.read(io::IO, ::Type{T})` method; it will be picked up by `tryget`,
90+
`get`, `walk(f, cur, K, V)`, and the cursor accessors `key`/`value`/`item`.
9191
Status-code matchers live on `LMDBError`:
9292

9393
```julia

docs/src/index.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
Memory-Mapped Database.*
55

66
LMDB is an embedded, memory-mapped, ACID key-value store developed by
7-
Symas for OpenLDAP. It is small, fast, and persists to disk while reading
8-
at near in-memory speeds — limited only by the size of the virtual address
9-
space.
7+
Symas for OpenLDAP. It persists to disk while reading at near in-memory
8+
speeds, limited only by the size of the virtual address space.
109

1110
```julia
1211
using Pkg; Pkg.add("LMDB")
@@ -18,16 +17,16 @@ LMDB.jl exposes the same database through three surfaces:
1817

1918
| Surface | What it offers | When to use |
2019
|---------|----------------|-------------|
21-
| **High-level interface** | `LMDBDict <: AbstractDict{K,V}` | When you want a persistent `Dict`. |
22-
| **Julia wrappers** | `Environment`, `Transaction`, `DBI`, `Cursor` | When you want explicit transactions and cursors with Julia-shaped wrappers. |
23-
| **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. |
20+
| 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. |
22+
| 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. |
2423

2524
`MDBValue`, `MDBArg`, and the [`MDBValueIO`](@ref LMDB.MDBValueIO)
2625
type sit between the C API and the Julia wrappers. `MDBValueIO` is an
2726
`IO` view over `MDB_val`; defining `Base.read(io, T)` on it is how you
2827
teach the typed reads about a custom value type.
2928

30-
The Usage section starts simple and gets more involved: [Essentials](@ref)
29+
The Usage section starts simple and gets more involved. [Essentials](@ref)
3130
has a working example, [Dictionary interface](@ref) covers `LMDBDict`,
3231
and [Environments](@ref), [Transactions](@ref), [Databases](@ref),
3332
[Cursors](@ref), and [Duplicate-sort databases](@ref) cover the wrappers.

docs/src/lib/cursors.md

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

77
A `Cursor` is a positioned iterator over the entries in a `DBI`. Cursors
8-
are bound to a transaction; closing the txn invalidates the cursor.
8+
are bound to a transaction. Closing the txn invalidates the cursor.
99

1010
## Construction
1111

docs/src/lib/databases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ tryget
3030
```
3131

3232
`get(txn, dbi, key, T, default)` falls back to `default` if `key` is
33-
missing — same shape as `Base.get(dict, key, default)`.
33+
missing, matching `Base.get(dict, key, default)`.
3434

3535
## Writes
3636

docs/src/lib/dict.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ Writes (`setindex!`, `delete!`, `pop!`, `empty!`) likewise. `delete!`
2323
silently no-ops on a missing key, matching `Base.delete!`'s "if any"
2424
contract.
2525

26-
Everything `AbstractDict` derives `merge!`, `merge`, `mergewith!`,
26+
Everything `AbstractDict` derives (`merge!`, `merge`, `mergewith!`,
2727
`filter!`, `filter`, `==`, `isequal`, `hash`, `in(::Pair, d)`,
28-
`copy(d)` comes along for free.
28+
`copy(d)`) comes along for free.
2929

30-
`LMDBDict` iterates in lexicographic key order, which is stronger than
30+
`LMDBDict` iterates in lexicographic key order, which is stricter than
3131
`Base.Dict`'s no-order promise.
3232

3333
## Lifecycle
3434

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

3838
## Prefix-scan helpers
3939

docs/src/lib/errors.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ CurrentModule = LMDB
66

77
Every LMDB-internal error surfaces as an `LMDBError` whose `code` field is
88
the raw status `Cint` returned by the underlying binding. Status-code
9-
matchers cover the three most common branches; less common codes can be
10-
matched against `LMDB.MDB_*` constants directly.
9+
matchers cover the most common branches; less common codes can be matched
10+
against `LMDB.MDB_*` constants directly.
1111

1212
## Exception type
1313

@@ -54,7 +54,7 @@ branch on `MDB_NOTFOUND`/`MDB_KEYEXIST` and friends.
5454

5555
At the Julia wrappers, handle methods that wrap status-returning
5656
bindings let `LMDBError` propagate. `tryget` and `get(..., default)`
57-
swallow `MDB_NOTFOUND` and return `nothing`/`default`;
57+
swallow `MDB_NOTFOUND` and return `nothing` or `default`.
5858
`delete!(txn, dbi, key)` likewise swallows `MDB_NOTFOUND` and returns
5959
`false`.
6060

docs/src/lib/lowlevel.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ for callers that need to inspect the raw status code.
1919

2020
Every status-returning binding in `liblmdb.jl` is paired with an
2121
`unchecked_*` companion at definition time. Use the bare name when any
22-
error should propagate (the common case); use `unchecked_*` when you
22+
error should propagate (the common case). Use `unchecked_*` when you
2323
need to inspect the raw `Cint` yourself, for example to distinguish
2424
`MDB_NOTFOUND` from a real error:
2525

@@ -34,15 +34,15 @@ Bindings that return non-status data (`mdb_strerror`, `mdb_version`,
3434
`mdb_txn_id`, `mdb_cmp`, `mdb_dcmp`, `mdb_env_get_maxkeysize`,
3535
`mdb_env_get_userctx`, `mdb_cursor_txn`, `mdb_cursor_dbi`) and
3636
`Cvoid`-returning ones (`mdb_env_close`, `mdb_dbi_close`,
37-
`mdb_txn_abort`, `mdb_txn_reset`, `mdb_cursor_close`) are left bare;
38-
there is nothing to check.
37+
`mdb_txn_abort`, `mdb_txn_reset`, `mdb_cursor_close`) are left bare,
38+
since there is nothing to check.
3939

4040
## Customisation point: `MDBValueIO`
4141

42-
`tryget` / `get` / `key` / `value` / `item` / typed `walk` / `pop!` /
42+
`tryget`, `get`, `key`, `value`, `item`, typed `walk`, `pop!`, and
4343
`replace!` all go through `read(::MDBValueIO, T)` to decode an
4444
`MDB_val` into a Julia value. Define a `Base.read` method on
45-
`MDBValueIO` to plug in a custom representation; see [Cursors](@ref)
45+
`MDBValueIO` to plug in a custom representation. See [Cursors](@ref)
4646
for a worked example.
4747

4848
```@docs

docs/src/man/cursors.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ CurrentModule = LMDB
55
```
66

77
A `Cursor` is a positioned iterator over a `DBI`. Use it for ordered
8-
scans, range queries, or when you want to amortise the per-lookup
9-
overhead of `mdb_get` across many keys.
8+
scans, range queries, or to amortise the per-lookup overhead of
9+
`mdb_get` across many keys.
1010

1111
## Opening a cursor
1212

@@ -21,19 +21,19 @@ end
2121
```
2222

2323
A cursor is bound to its transaction; closing the txn invalidates the
24-
cursor. The cursor's finalizer is idempotent, so a still-open cursor
25-
is reclaimed when GC visits it.
24+
cursor. The cursor's finalizer is idempotent, so a still-open cursor is
25+
reclaimed when GC visits it.
2626

2727
## Navigation
2828

2929
Each navigation function repositions the cursor and returns the new
3030
key, or `nothing` if the move would step past the end:
3131

3232
```julia
33-
seek!(cur) # MDB_FIRST first entry
34-
seek_last!(cur) # MDB_LAST last entry
35-
seek!(cur, key) # MDB_SET_KEY exact key match
36-
seek_range!(cur, key) # MDB_SET_RANGE smallest key ≥ `key`
33+
seek!(cur) # MDB_FIRST first entry
34+
seek_last!(cur) # MDB_LAST last entry
35+
seek!(cur, key) # MDB_SET_KEY exact key match
36+
seek_range!(cur, key) # MDB_SET_RANGE smallest key ≥ `key`
3737
next!(cur) # MDB_NEXT
3838
prev!(cur) # MDB_PREV
3939
```
@@ -80,24 +80,24 @@ start(env; flags = MDB_RDONLY) do txn
8080
end
8181
```
8282

83-
For the same pattern *one level up* (already wrapped, returns a
83+
For the same pattern one level up (already wrapped, returns a
8484
`Vector{Pair}`), use [`LMDB.scan(d; prefix)`](@ref LMDB.scan) on an
8585
`LMDBDict`.
8686

87-
## [Bulk walk zero-copy iteration](@id man-cur-walk)
87+
## [Bulk walk: zero-copy iteration](@id man-cur-walk)
8888

8989
`walk` runs a callback over every entry the cursor visits. It exists in
9090
two shapes:
9191

9292
```julia
93-
# Untyped receives Ref{MDB_val} pairs (zero-copy, mmap pointers)
93+
# Untyped: receives Ref{MDB_val} pairs (zero-copy, mmap pointers)
9494
walk(cur) do k_ref, v_ref
9595
kv = k_ref[]; vv = v_ref[]
9696
# kv.mv_data / vv.mv_data are mmap pointers, valid in this scope
9797
do_something(kv.mv_size, vv.mv_size)
9898
end
9999

100-
# Typed runs each ref through `read(MDBValueIO, K)` / `read(MDBValueIO, V)`
100+
# Typed: runs each ref through `read(MDBValueIO, K)` / `read(MDBValueIO, V)`
101101
walk(cur, String, Vector{UInt8}) do k::String, v::Vector{UInt8}
102102
println(k, " => ", length(v), " bytes")
103103
end
@@ -110,12 +110,12 @@ The callback can return `false` to stop iteration; any other return
110110
(including `nothing`) continues.
111111

112112
Use the untyped form when you want to inspect raw byte sizes, copy
113-
slices, or feed a custom decoder; the data pointers are into LMDB's
113+
slices, or feed a custom decoder. The data pointers are into LMDB's
114114
mmap and are valid only inside the callback (and only for the
115115
surrounding txn). The typed form is the iteration analogue of
116116
`tryget(..., T)` and works for any `T` for which `Base.read(io::IO,
117117
::Type{T})` (or `Base.read(io::LMDB.MDBValueIO, ::Type{T})`) is
118-
defined; see [Custom value decoding](@ref).
118+
defined. See [Custom value decoding](@ref).
119119

120120
## Cursor mutation
121121

@@ -134,14 +134,14 @@ key (1 in non-DUPSORT databases).
134134

135135
## Custom value decoding
136136

137-
`tryget` / `get` / `key` / `value` / `item` / typed `walk` all funnel
137+
`tryget`, `get`, `key`, `value`, `item`, and typed `walk` all funnel
138138
through `Base.read(io::IO, ::Type{T})` against an
139139
[`MDBValueIO`](@ref LMDB.MDBValueIO). The defaults cover Base's
140140
primitive numeric types (`Int8`/…/`Float64`, `Bool`, `Char`, `Ptr`),
141141
`String`, and (added by this package) `Vector{E}` for any bitstype `E`.
142142

143143
For everything else, including `isbitstype` structs and framed
144-
values, define a single `Base.read` method on the abstract `IO`:
144+
values, define a single `Base.read` method on the abstract `IO`.
145145

146146
```julia
147147
struct PrefixedBlob end
@@ -165,7 +165,7 @@ end
165165
decoders end up reading like any other Julia binary parser, and the
166166
same decoder works against any byte source. This is the analogue of
167167
heed's `BytesDecode<'txn>` trait, expressed through Julia's existing IO
168-
extension point rather than a bespoke trait.
168+
extension point instead of a bespoke trait.
169169

170170
## Reset and renew
171171

docs/src/man/databases.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ open(txn, "users") do dbi
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 DBI handle explicitly. The
2828
env owns it, and `mdb_dbi_close` is documented as rarely useful. The
2929
env's finalizer cascades through any open DBI handles.
3030

@@ -53,8 +53,8 @@ get(txn, dbi, key, T, default) # default on miss
5353
```
5454

5555
`T` is anything `read(::LMDB.MDBValueIO, ::Type{T})` knows how to
56-
decode `String`, `Vector{E}` for any bitstype `E`, or any bitstype
57-
scalar:
56+
decode: `String`, `Vector{E}` for any bitstype `E`, or any bitstype
57+
scalar.
5858

5959
```julia
6060
tryget(txn, dbi, "name", String) # → Union{String, Nothing}
@@ -82,7 +82,7 @@ Useful write flags:
8282
|------|---------|
8383
| `MDB_NOOVERWRITE` | fail with `MDB_KEYEXIST` if `key` is already present |
8484
| `MDB_NODUPDATA` | (DUPSORT) fail if the `(key, val)` pair already exists |
85-
| `MDB_APPEND` | append; only valid if the new key sorts after every existing key*much* faster for sorted bulk loads |
85+
| `MDB_APPEND` | append; only valid if the new key sorts after every existing key. Much faster for sorted bulk loads |
8686

8787
```julia
8888
# Bulk import in sorted order:
@@ -98,7 +98,7 @@ end
9898
`replace!` and `pop!` do the read-modify pair inside the same
9999
transaction, so there is no time-of-check / time-of-use gap.
100100

101-
## `put_reserved!` write directly into the mmap
101+
## `put_reserved!`: write directly into the mmap
102102

103103
When the value is large or assembled from multiple sources, you can
104104
skip the intermediate `Vector{UInt8}` round-trip and write straight
@@ -115,8 +115,8 @@ end
115115
inside the callback, and only inside the surrounding write txn; don't
116116
escape it.
117117

118-
`put_reserved!` is the equivalent of heed's `Database::put_reserved`,
119-
and is incompatible with DUPSORT.
118+
`put_reserved!` is the equivalent of heed's `Database::put_reserved`.
119+
It is incompatible with DUPSORT.
120120

121121
## Stats
122122

@@ -137,4 +137,4 @@ drop(txn, dbi; delete = true) # delete the DB and close the handle
137137

138138
For named sub-DBs, `delete = true` removes the entry from the env's
139139
main DB. For the main DB itself, `delete = true` is treated as
140-
`delete = false` (LMDB cannot delete its own root).
140+
`delete = false`, since LMDB cannot delete its own root.

docs/src/man/dict.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ tasks.
3636
## Storing and retrieving
3737

3838
Anything that round-trips through the package's `MDB_val` glue and
39-
[`MDBValueIO`](@ref LMDB.MDBValueIO) works as a value type `String`,
39+
[`MDBValueIO`](@ref LMDB.MDBValueIO) works as a value type: `String`,
4040
`Vector{T}` for any bitstype `T`, and any bitstype scalar (`Int`,
4141
`Float32`, `(Int, UInt32)` `Tuple`, …).
4242

@@ -66,7 +66,7 @@ for (k, v) in d
6666
end
6767
```
6868

69-
Iteration is in **lexicographic key order** — strictly stronger than
69+
Iteration is in lexicographic key order, which is stricter than
7070
`Base.Dict`'s no-order promise. Each `for` loop opens a fresh read
7171
transaction; the txn is committed on normal exit and aborted (via the
7272
`Transaction` finalizer) on early break or throw.
@@ -97,7 +97,7 @@ filter!(((k, v),) -> v > 0, d)
9797
## Prefix-scoped scans
9898

9999
For hierarchical key schemes (e.g. `"users/123/name"`), LMDB's
100-
lexicographic order makes prefix scans cheap — they're a single
100+
lexicographic order makes prefix scans cheap: a single
101101
`MDB_SET_RANGE` plus iteration until the prefix stops matching.
102102

103103
```julia
@@ -119,15 +119,15 @@ LMDB.scan(d, prefix = "users/2/")
119119
# "users/2/name" => "Bob"
120120
```
121121

122-
For directory-style listingsleaf keys appear as-is, anything with
122+
For directory-style listings, leaf keys appear as-is and anything with
123123
the separator after the prefix collapses to its first segment:
124124

125125
```julia
126126
LMDB.list_dirs(d, prefix = "") # ["other", "users/"]
127127
LMDB.list_dirs(d, prefix = "users/") # ["users/1/", "users/2/"]
128128
```
129129

130-
`LMDB.valuesize(d; prefix)` sums byte sizes — useful for quick storage
130+
`LMDB.valuesize(d; prefix)` sums byte sizes. Useful for quick storage
131131
audits without `stat`.
132132

133133
## When to drop down

0 commit comments

Comments
 (0)