sentstore — a document-sharded, append-only store of sentence records
sentstore keeps sentence records grouped by document: one JSON record per document (or per part of a document that
one batch added), each sentence with its id, position and text and any number of other fields (context, parse
layers, provenance). The same sentence text in two documents is two records, because its context and its parses may
differ. It is the store of the continuous corpus pipeline (Text corpora from 0.6); the format is
generic.
cargo build --release -p sentstore
sentstore get DIR DOC SENT # one sentence: its id, #N (its number) or =TEXT (its exact text)
sentstore doc DIR DOC # one document, its parts from every batch joined
sentstore info DIR # shard count and committed batches
sentstore verify DIR # segments against their commits, every document read, keys complete
sentstore compact DIR [SHARD] # merge a shard's segments (every shard without SHARD)
From Rust: Store::create(dir, shards), store.append(batch, &records, &meta), store.get(doc, &Sel::parse(sent)),
store.keys() (every committed (document, sentence) pair: what a sampler draws without replacement against).
How it works
- Shards. A document's shard is FNV-1a of its id modulo the shard count, fixed when the store is created (256 shards keep millions of sentences in shards of tens of megabytes). Every part of a document lies in its shard.
- Batches append. A batch writes one new segment per shard it touches,
shard-NNNN/seg-<batch>.mpk(JSON lines packed withmova-pack: templates, zstd blocks with a record index, checked by unpacking before it is written) with its document indexseg-<batch>.idx, thenkeys/<batch>.tsv, and last the commit markerbatches/<batch>.json. A segment counts only once its batch is committed, so a crash leaves nothing half-visible; an uncommitted batch is moved to.aside/and written again. No batch rewrites a shard. A batch that repeats a committed(document, sentence)key is refused. - Compaction merges a shard's live segments into one (
seg-c<last batch>.mpk) and switcheslive.jsonto it with one rename; the old segments move to.aside/. Reads are the same before and after. - Reading a document reads the index of each live segment of its shard and decodes one block per segment.
Checks
cargo test --release -p sentstore: batches append to their shards without rewriting them, a document grows across
batches, the same text in two documents stays two records, compaction keeps every read, a repeated key and malformed
records are refused, an uncommitted segment is invisible and redone, and (negative control) a corrupted segment
fails verify.
Limits
- One writer at a time; no locking.
- Each read decodes one block per live segment of the shard: compact shards with many segments.
- Small batch segments are packed without a trained zstd dictionary (it pays from about 1 MB).
.aside/is never emptied by the store itself.
This page in Markdown https://md.mova.elamur.ai/free/en/docs/tools/sentstore/