Expand description
Stable file-format, reader, and in-memory build API.
Structs§
- Build
Info Plan - Everything needed to splice a build-info section into a finished file without holding the file in memory: the rewritten header, where the section goes, and where the bytes that do not move resume.
- Build
Stats - Counts describing an assembled file, for status lines and UIs.
- Byte
Range - A byte range in the
.retefile image. - Card
Append Plan - What placing a new card after a file’s data does to its layout — see “The card after the data” in the module docs.
- Card
Rewrite Plan - What a card rewrite does to a file’s layout.
- Deferred
Metadata - A metadata payload whose final form needs the written (deduplicated) counts.
See
IntoMetadata. - Dump
Plan - What a filtered dump will cost, before it runs — see
Rete::dump_plan. - Final
Counts - The deduplicated counts of the file being written — what the header records, and therefore what any embedded metadata has to report.
- Header
- Decoded file header. All multi-byte fields are little-endian on disk. The
*_offset/*_lenfields are a convenience view over the section directory (populated from it on parse, emitted back to it on serialize). - Layout
Segment - One labelled byte region of a
.retefile image (seeRete::file_layout).kindis a stable machine tag:header,metadata,dictionary,directory,tile,pyramid,named-graphs. - Rete
- A read-only, in-memory view over a
.retefile image. - Scan
Plan - What a routed scan of one pattern will touch, from the tile directories
alone — see
GraphIndex::scan_plan. - Section
- One parsed/encoded section-directory entry: a typed
(offset, length)into the file, plus 16 bits of per-section flags (reserved). - Triple
Provenance - Why a triple-pattern result is present in the file.
Enums§
- File
Error - Graph
Layout - How a build stores the named graphs (the default graph is unaffected).
- Header
Error - Ingest
Error - Why an ingest failed. Parser errors from
oxttl/oxrdfxmland I/O errors are flattened to theirDisplaystring rather than wrapped: the variants then carry no foreign types, which keeps the error usable from the wasm bindings and stable across upstream parser upgrades. - Pyramid
Layout - What a pyramid-meta section carries besides the community summary.
- Quoted
Triple Surface - Which surface a
<< … >>in Turtle/TriG input is read as — the input half ofrete export --quoted-triple-syntax, same vocabulary, same two values. - Section
Kind - A top-level file section, addressed by
SectionKindin the header directory.
Constants§
- CODEC_
NONE - No compression.
- CODEC_
ZSTD - zstd compression (per section).
- CURRENT_
FORMAT_ VERSION - Current format generation written by this crate.
- HEADER_
LEN - Fixed header size in bytes.
- MAGIC
- Magic bytes at offset 0: ASCII
RETE. - MIN_
STABLE_ READ_ VERSION - Oldest stable format generation accepted by this reader.
- RDF_
TYPE rdf:type— the predicate that assigns a class to a resource.- REWRITE_
CHUNK - How the rewriter moves bytes: large enough to keep a disk streaming, small enough that the peak memory of a 26 GB rewrite is this and nothing else.
Traits§
- Into
Metadata - What a build’s metadata callback may return.
Functions§
- append_
sections - Append LABEL_INDEX / SCHEMA sections (kinds 8, 9) to a finished file image, just before its 4-byte footer, and return the new image.
- assemble_
dataset - Assemble a complete
.retefile image from parsed quads: one shared dictionary, the default-graph index, one index per named graph, and the community pyramid.metadatais the opaque metadata-section payload (the CLI puts a JSON Dataset Card there); pass&[]for none — that is byte-identical to a metadata-free build. - assemble_
dataset_ with - Like
assemble_dataset, but the metadata payload is derived from theBuildStatsand the source quads while they are still resident — for metadata that describes the graph (the Dataset Card). Returning an emptyVecis byte-identical to a metadata-free build; return aDeferredMetadatafor a payload that must also carry the file’s deduplicated counts, which exist only once the indexes are built. - assemble_
dataset_ with_ layout - Like
assemble_dataset_with_perms, storing the named graphs ingraphslayout.GraphLayout::PerGraphreproduces it exactly. - assemble_
dataset_ with_ opts - Like
assemble_dataset_with, butwith_pyramid = falseskips the Louvain community pyramid entirely — no pyramid section is written (header length 0). SPARQL / SHACL / triple / reachability queries don’t use the pyramid, so a pyramid-less file is fully queryable and markedly smaller (the pyramid is the largest section on highly-connected graphs). Only the community / summary / progressive paths need it. - assemble_
dataset_ with_ opts_ algo - Like
assemble_dataset_with_opts, but selects the communityPyramidAlgo(the in-memory build path forrete build --pyramid-algo …). - assemble_
dataset_ with_ perms - Like
assemble_dataset_with_opts_algo, but writes only the permutations inperms(rete build --permutations 3). Every other byte of the file is unchanged;crate::index::PermSet::ALLreproduces the default build exactly, down to the header byte. - attach_
build_ info - Attach (or replace) a build-info section in a finished file image,
returning the new image. Layout and hash semantics:
plan_build_info. - card_
append_ hash - Fold the content hash the file will have once
planis committed withmetadataas its card: the card from memory, every other hashed section read fromsrc(the file as the plan found it) inREWRITE_CHUNKslices.progressgets the bytes read so far. The build record does not take part — it is outside the hash — which is what lets a caller seal it after this, its longest step, and still commit it in the same write. - commit_
card_ append - Commit
plan: writemetadata, thenbuild_info(outside the hash, so it may be sealed aftercard_append_hash), then a footer at the plan’s card offset, cut the file there, sync, and only then rewrite the 1 KiB header withhashand the new section entries, and sync again. Returns the header written. - content_
hash_ parts - The byte ranges the content hash folds, in the order it folds them: the metadata payload when present, then dictionary, index, pyramid-meta, and — when present — a kind-6 text index and the named graphs. Build info, the self-digested kinds (8 LABEL_INDEX, 9 SCHEMA, 11 predicate-restricted text index) and any section kind this reader does not know are deliberately outside it. The quad index (kind 10) is not a range here either: its digest is the seal at the end of the index container, so it is hashed by reference.
- parse
- Parse N-Triples text into raw term-token triples, skipping blank/comment lines.
- parse_
quads - Parse N-Quads text:
subject predicate object [graph] .per line. - parse_
rdfxml - Parse RDF/XML into canonical N-Triples-token triples via oxrdfxml. This is how
most OWL ontologies ship (
.rdf/.owl/.xmlwith anrdf:RDFroot) — so rete ingests them directly, no external conversion. (OWL/XML — the non-RDF functional XML serialization — is a different language; convert it with owlready2 first.) - parse_
statements - Parse one text input by format name (
"nt","nq","ttl","trig", or"rdfxml") into quads (triples land in the default graph). - parse_
statements_ audited_ surface parse_statements_auditedreading<< … >>in the givenQuotedTripleSurface. This is the entry pointrete buildandrete validateuse for everything but a streamed line-based input, and the one that turns “RDF 1.2 file, RDF-star reader” into an error that names the flag instead of a bare syntax complaint.- parse_
turtle - Parse Turtle into canonical N-Triples-token triples via oxttl, reading
<< s p o >>as an RDF-star quoted triple.parse_turtle_surfacechooses. - parse_
turtle_ surface parse_turtlein the givenQuotedTripleSurface.- plan_
build_ info - Plan the splice of a build-info section of
info_lenbytes into a file whose firstHEADER_LENbytes areheadand whose total length isfile_len. - plan_
card_ append - Plan placing a card of
metadata_lenbytes (0= none) after the data of the file whose firstHEADER_LENbytes areheadand whose length on disk isfile_len. - plan_
card_ rewrite - Plan replacing the metadata and build-info sections of a file whose first
HEADER_LENbytes areheadand whose length isfile_len, with sections ofmetadata_lenandbuild_info_lenbytes (0= none). - read_
build_ info - The build-info section of a whole file image, or
Noneif absent. The payload is an opaque application-layer blob (the CLI stores build-conditions JSON there); it is not covered by the content hash — seeattach_build_info. - replace_
metadata - Replace the metadata section (the Dataset Card blob) of a finished file image, returning the new image. The section is the first one after the header, so every later section’s offset shifts by the length delta.
- rewrite_
card - Rewrite
srcintooutwithmetadataas its card andbuild_infoas its build record (either may be empty, which removes the section), copying every other section verbatim and folding the new content hash on the way. Returns the header written at offset 0. - verify
- Recompute the content hash from a file image and check it against the header
— detects corruption or truncation of the payload sections. The
LABEL_INDEX, SCHEMA and predicate-restricted TEXT_INDEX sections (kinds 8,
9, 11) are outside that hash — an older reader’s
verifymust keep passing on a file that carries them — so each is checked against its own leading digest instead. The QUAD_INDEX section (kind 10) is hashed by reference: its digest is the seal inside the (hashed) index container, checked here.
Type Aliases§
- RawQuad
- A parsed quad: the triple plus an optional graph term (
None= default graph). - RawTriple
- A parsed triple as three canonical term tokens.
- Term
Triple - A resolved triple as terms.