readcon-db
Mmap-backed CON/convel corpus store (LMDB via Heed), non-SQL selection, xxHash3-128 exact match, and Rust / C / C++ / Python / Fortran bindings.
Part of the readcon ecosystem with readcon-core (Python package readcon):
| Crate / package | Role | Docs |
|---|---|---|
readcon-core / readcon |
CON interchange (parse/write/spec v2–v3). XYZ/PDB/GRO → ConFrame via chemfiles (read_chemfiles*), not ASE. Optional to_ase only for calculators. |
Core README, docs/orgmode/ |
readcon-db / readcon_db (this repo) |
mmap CON corpus: indexes (natoms, symbols, energy range, forces/velocities/energy flags), multi-reader, dedup. Blobs are CON text decoded with readcon-core. | docs, docs/orgmode/explanation/design.org |
ASE is not on the CON or XYZ read path. Optional to_ase is calculator hand-off only.
Install
# C/C++: FetchContent / meson dependency('readcon-db') / pkg-config
# headers in include/ are shipped; cbindgen is not required
# Prebuilt C ABI (no cargo): readcon-db-clib-$VER-$target.tar.gz on the GitHub Release
Docs: https://lode-org.github.io/readcon-db/ · crate: https://crates.io/crates/readcon-db
Quick start (from source)
Optional LODE sibling checkout (edit core + db together): clone both under the same parent, then create untracked .cargo/config.toml in readcon-db:
[]
= { = "../readcon-core" }
Python extension from a checkout (python/ + maturin):
use ;
let db = open?;
db.append_trajectory_path?;
// XYZ in: use readcon-core chemfiles → ConFrame → append (see workflows)
let keys = db.select?;
let h = db.frame_hash?;
Foreign trajectories: readcon.read_chemfiles("traj.xyz") → frames → ingest into readcon-db (chemfiles-enabled build), not ase.io.read.
Design
- No SQL engine — explicit indexes + in-process intersection, with ASE.db-competitive screening fields (mass, volume, PBC, reserved metadata, charge/magmom; see design matrix).
- Decode via readcon-core — CON semantics never fork.
- Metadata indexes — finite
energybins; flags for forces, velocities, energy presence. - xxHash3-128 on the CON text. A new
framesvalue is0xFD 0x01plus one zstd level-1 frame of that UTF-8, written outside the LMDB transaction. An aligned run of 64 frames shares one0xFD 0x03zstd frame when that group is shorter than the per-frame values, and the other keys store a0xFD 0x02redirect. Untagged UTF-8 still reads as a 0.1.8 span.readcon-db migraterewrites legacy values once and leaves an already packed value unchanged.--no-compressoningest,ingest-dir, andshard-ingeststores the UTF-8. There is no dictionary. Both MPI ingest routes send the stored bytes. The hash is the decompressed text. - Many readers, one writer (LMDB). Same-frame MPI: rank 0 of the
caller communicator packs RCSO and
MPI_Bcaston that handle (include/readcon-db-mpi.h, Pythonbcast_packed_frame/bcast_packed_frames). The library neverMPI_Inits and never names the process-wide world communicator; LAMMPS / mpi4py pass the comm they already own. - H5MD interchange —
export_h5md/collect_h5mdwrites one[T][N][3]trajectory (CON stays authority). Engine dest is Å / ps / kJ mol{-1} Angstrom{-1}; velocity dest isAngstrom ps-1. Velocities follow D10: v1, v2, and v3.0 frames use the natural unit(amu*angstrom^2/eV)^0.5whatever the time label says; v3.1 frames useunits.timeand fail when a velocities section has nounits.time.--velocity-time-unit, RustH5mdCollectOpts, the Pythonvelocity_time_unitargument, and Crkrdb_set_velocity_time_unitoverride that rule for a file that breaks it. The simulation clock usesunits.timewhen that key is present. A v3.1 frame withtimeortimestepand nounits.timeis an error. The same override supplies that missing clock unit. A presentunits.timestill scales the clock. v1, v2, and v3.0 clocks with nounits.timeare read asfs. - Node-local drain/join —
shard-ingestthendrainto a unique dest (data.mdbonly, refuse overwrite), thenjoin-drained.compact-joinjoins one sharded root (open_existing). Campaign ops:docs/orgmode/howto/campaign.org.
Full ABI table, logo, Sphinx docs, and site: see docs/, website/, assets/logo/, CHANGELOG.md. Fortran module notes: fortran/README.md, fortran/ReadConDb/.
License
MIT
Cooked SoA tier
Optional RCSO numerics in frames_soa (opt-in cook). Ingest and migrate do not cook. RCSO is
non-authoritative: CON text in frames is the sole authority for hash,
dedup, join/split, and reindex. User doc:
docs/orgmode/cooked-soa.org.