Expand description
rete-graph — the Rust library for Rete
graph files, under the name it already has on PyPI and npm.
This crate is a facade: every item is re-exported from
rete_core, which is where the engine actually
lives and where the implementation documentation belongs. Depending on either
gets you the same code; this one exists so that
pip install rete-graph # Python
npm install rete-graph # JavaScript
cargo add rete-graph # Rustall name the same thing. Before it existed, a Rust user following any of the project’s other install instructions had to know that the crate was called something else.
§What this is NOT
It does not pull in the whole workspace, because the three published crates are not interchangeable:
rete-coreis the library — what a Rust program depends on, and what this crate re-exports.rete-cliis a binary. You install it (cargo install rete-cli); depending on it from a library would drag an executable into your build for nothing.rete-wasmis the browser binding, meaningful only onwasm32targets.
PyPI’s and npm’s rete-graph are likewise the library for their language,
not the CLI, so re-exporting the library is the faithful mapping.
§Features
compression (default), parallel and wasm-js are forwarded verbatim to
rete-core, so this crate can be configured exactly like it.
§Example
use rete_graph::Rete;
let bytes = std::fs::read("graph.rete")?;
let graph = Rete::open(&bytes)?;
println!("{} quads", graph.dump(None).len());Modules§
- card
- Stable Dataset Card API — both halves of a card, so that every writer
(
rete build --card-file, the browser builder, any language binding, any third-party tool) produces the same card from the same graph. - format
- Stable file-format, reader, and in-memory build API.
- geo3
- A 3D extension of the GeoSPARQL built-ins (
geo3). - ingest
- Ingestion: parse RDF text (N-Triples / N-Quads / Turtle) and assemble a
complete
.retefile image. Shared by the CLI’sbuild/validatecommands and the wasm bindings (the playground’s in-browser builder). - iri
- IRI validity — what may appear between the angle brackets of an
N-Triples / N-Quads
IRIREF, and the one lossy repair the exporter offers. - manifest
- Manifest — a writable logical graph as an ordered log of immutable
.retesegments. - query
- Stable SPARQL, graph-pattern, federation, and result API.
- range
- Stable byte-range and lazy-open API for local or remote
.retefiles. - reasoning
- Stable RDFS/OWL reasoning and schema-coherence API.
- validation
- Stable integrity and SHACL validation API.
Structs§
- Block
Cache Reader - 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.
- Byte
Range - A byte range in the
.retefile image. - CharSet
- A characteristic set — one entity “shape”: the sorted set of predicates a subject carries, plus how many subjects share exactly that shape. Computed at build (top-N shapes by subject count), range-fetched with the pyramid. Useful for data profiling (the distinct entity shapes) and for estimating the selectivity of a subject star (subjects matching ALL of several predicates).
- Class
Node - One node of the shipped
subClassOfDAG: a class, all its direct parents, and itsdepth(0 = root). The hierarchy is non-exclusive — a class may have several parents (multiple inheritance), so this is a directed acyclic graph, not a tree. The first parent (parents are sorted) is the canonical one used for the depth/rollup spanning tree; the rest preserve the cross-links. - Class
Relation - A class-to-class relation (the lateral, non-
is-aconnection): subjects ofs_classrelated bypredicateto objects ofo_class, with the instancecount.(literal)/(untyped)are the object-class sentinels. - Community
Descriptor - A per-community refinement descriptor (Phase 4): what a client sees when it zooms into one community, without fetching that community’s triples. Carries the dominant class, the local type histogram, and optional spatial/temporal extents. (The physical per-community triple tiles are still future work; this descriptor index ships in the index-free pyramid-meta and is ready to attach to those tiles when they exist.)
- Community
Partial - One community’s contribution to a community-split evaluation: how many member subjects it holds and how many solution rows it produced.
- Counting
Reader - Wraps a reader and tallies how many ranges were requested and how many bytes
were returned — the metric that matters for a range-streamed format.
Atomically counted, so it stays
Sync(a lazily-faulting remote index holds its reader behind a shared loader). - Data
Graph - A validation data graph held fully in memory as a sorted triple vector. Backs
the shapes graph and the eager data path; the lazy data path uses
ReteGraph. - Dendrogram
- A hierarchy of community partitions (a dendrogram).
levels[0]partitions the base nodes;levels[k]partitions levelk-1’s communities. Round 0 is the finest grouping; the last round is the coarsest (pyramid level 0). - Dict
Section - A parsed, read-only dictionary section (parses its metadata on construction).
- Dict
Section Builder - Build a dictionary section from terms (any order; sorted + deduped here).
- Dictionary
- A read-only dictionary mapping terms ↔ role-specific IDs.
- Dictionary
Builder - Builds a
Dictionaryfrom observed(subject, predicate, object)terms. - Dump
Plan - What a filtered dump will cost, before it runs — see
Rete::dump_plan. - Graph
- A weighted undirected graph over nodes
0..n. Parallel edges are summed; self-loops are kept (they affect modularity but not community moves). - Graph
Index - The six tiled permutation sections, queryable by triple pattern.
- Graph
Index Builder - Build a
GraphIndexfrom canonical(s, p, o)integer triples. - Group
Directory - A byte-offset directory of a block’s a-groups: one entry per group, sorted
by leading id (the storage order). Built once per block with
TripleBlock::group_directory;TripleBlock::scan_fromthen binary-searches it to jump a probe straight to its group. - Group
Spec - GROUP BY specification: grouping variables and result aggregates.
- 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). - Inconsistency
- One detected incoherent point (a logical contradiction in the graph).
- IriReport
- A bounded tally of invalid IRIs — the shape both the build-time audit and the export-time sanitizer report.
- Label
Entry - One entry of the label index: the display label of a subject (its
rdfs:label/skos:prefLabel/ … literal) paired with that subject’s id. Computed at build (the most-connected labeled subjects, bounded), the table is sorted by the label’s lowercased form so a prefix query is a binary search — autocomplete and CONTAINS/prefix lookup without scanning the literals. Range-fetched with the pyramid; the label string is stored inline so the search is self-contained on the remote-lazy path (no dictionary fault). - 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. - Level
Links - The class-relation graph rolled up to
depth— the lateral connections at one semantic-zoom level. Coarse levels show relations between abstract classes (Agent → Agent); finer levels resolve them (Person → Organisation). This is what makes the pyramid a leveled graph, not just a leveled histogram. - Level
Rollup - A type histogram rolled up to
depth— the global class distribution at one semantic-zoom level. Coarse levels (small depth) hold abstract ancestor classes; fine levels (large depth) resolve to leaves.roundis the dendrogram round this level is aligned with (informational). - Level
Stats - What one Louvain level did (for tests and the termination harness).
- Memory
Budget - How a total
--memory-budget-mbsplits across the export’s three bounded consumers. The window’s per-row string buffer and the id buffer are small (bounded by the fixed window row count, not the file), so they are left in the slack between this sum and the total rather than given a named cap; peak RSS is therefore≈ total + window_string_buffer + fixed open overhead. - Offset
Reader - Wraps a
RangeReaderso every access is shifted bybasebytes: a.retethat starts at bytebaseof the backing resource — e.g. behind an HTML shell in a polyglot file that is both a web page and a graph — reads exactly as if it began at offset 0, lazily, touching only the.retebytes a query needs and never the prefix. Pair withdetect_polyglot_baseto findbase. - Partition
- A community partition with dense IDs
0..count. - PermSet
- Which permutations a file stores — a 6-bit set over
IndexPermutation::section_index, recorded in the header so a reader never has to assume six. - Pred
Stat - Per-predicate cardinality statistics for the cost-based query planner —
computed at build, range-fetched with the pyramid (index-free).
countis the triple total; the distinct-subject/object counts and max multiplicities let the planner estimate a bound subject’s/object’s selectivity (functionaliffmax_objects_per_subject == 1, inverse-functional iffmax_subjects_per_object == 1). - Pyramid
Meta - Decoded pyramid metadata.
- Query
Opts - Evaluation options for
eval_query_with. Every flag defaults to off, and off reproduceseval_querybyte-for-byte — the W3C conformance suite runs with this default. - Query
Warning - One diagnostic about a query evaluation: a counted class of type errors, or
a hint. Returned by
eval_query_with_warnings. - Reasoning
- The result of reasoning over a base graph.
- Rete
- A read-only, in-memory view over a
.retefile image. - Rete
Graph - A SHACL data-graph view backed directly by a
.retefile’s index: every lookup is a routed pattern query, so over a lazy (Rete::open_ranged_lazy) open a validation faults only the tiles holding the shapes’ target nodes — not the whole graph. Views the default graph (named-graph validation uses the eagerDataGraph). - Routed
Triple Pattern - A single triple pattern that can be answered by the range-routed permutation
reader.
Nonemeans the position is a variable/wildcard;Some(term)means the query pins that term. - Scan
Plan - What a routed scan of one pattern will touch, from the tile directories
alone — see
GraphIndex::scan_plan. - Search
View - A
.reteopened for search only: the dictionary’s chunk directories, and the TEXT_INDEX / pyramid deferred behind their lazy slots. Nothing else. - Section
- One parsed/encoded section-directory entry: a typed
(offset, length)into the file, plus 16 bits of per-section flags (reserved). - Select
- A lowered SELECT query: solution modifiers plus the evaluation plan tree.
- Shacl
Shapes - Parsed SHACL shapes graph.
- Slice
Reader - A
RangeReaderover an in-memory byte slice (tests, embedded files). - Summary
View - A lightweight, overview-only view of a file: the pyramid summary graph plus just enough dictionary to label predicates. Fetched via ranges without touching the (large) triple index — the “load the coarse graph first” path from SPEC.md §7.2.
- Super
Edge - An aggregated relation between two communities in the summary graph.
- Text
Index - A parsed text index: the token table (always resident) plus a posting source.
- Text
Index Builder - Accumulates
token → subjectsand serializes the section. - Tile
- One tile: a community’s triples and their encoded SPO block.
- Triple
Block - A parsed triple block.
- Triple
Block Builder - Accumulates triples and serializes a block.
- Triple
Pattern - A triple pattern
(subject, predicate, object)ofPatternTerms. - Triple
Provenance - Why a triple-pattern result is present in the file.
- Validation
Report - Validation
Result - ZoneMap
- Per-block summary statistics enabling block-skipping.
Enums§
- Agg
- A supported aggregate function.
- FExpr
- A small boolean/comparison expression for FILTER (a subset of SPARQL exprs).
- Graph
Target - The target of a
GRAPHblock. - Header
Error - Index
Permutation - Which stored permutation to scan. The full six orders (a SPARQL engine’s
classic set, as in QLever): together they sort the triples on every prefix
of
(s, p, o)columns, so for any bound-component prefix and any free component there is a permutation that routes on the prefix and yields the stream sorted on that free component — the precondition for a merge join. - IriDefect
- Why an IRI is not one — a repair classification, not the validity
verdict.
iri_content_defectdecides validity with an RFC 3987 parser and uses these only to say what, if anything, can be done about it. - Op
- Comparison operators supported in FILTER.
- PathAst
- A lowered property path expression, evaluated as a binary relation over the graph’s nodes.
- Pattern
Term - A term in a pattern: a named variable or a constant term token.
- Plan
- A SPARQL graph-pattern evaluation plan (the supported algebra subset).
- Pyramid
Algo - Which algorithm forms the pyramid’s communities. The format and every
downstream consumer key on opaque community IDs, so the choice only changes
how the partition is computed — all modes must be deterministic to keep the
file content-hash reproducible (see
docs/BENCHMARK.md). - Query
Output - The result of evaluating any SPARQL query form.
- Rep
- Path repetition operator.
- Section
Kind - A top-level file section, addressed by
SectionKindin the header directory. - Severity
- Shacl
Error - Sparql
Error - Summary
Query Shape - Query shapes that can be answered exactly from
crate::range::SummaryViewpredicate totals, without opening the triple index. - Warning
Severity - How serious a
QueryWarningis.
Constants§
- CODEC_
NONE - No compression.
- CODEC_
ZSTD - zstd compression (per section).
- CURRENT_
FORMAT_ VERSION - Current format generation written by this crate.
- DEFAULT_
BLOCK - Default block size: 64 KiB — large enough to swallow a dictionary chunk or an index tile in one fetch, small enough to keep over-fetch modest.
- DEFAULT_
CACHE_ CAP - Default cap on resident cached bytes: 256 MiB. Large enough that a working set (the tiles + dictionary chunks a query family touches) stays warm; small enough that a full sweep of a multi-GB file leaves plenty of the 32-bit wasm address space for the decompressed structures built on top of these bytes. At the auto-tuned 128–512 KiB block sizes this is 512–2048 resident blocks, so the eviction scan is trivial.
- DEFAULT_
EXPORT_ BUDGET_ MB - The default
rete export --memory-budget-mbwhen the flag is omitted — the same numberrete build/mergedefault to, so one figure governs both the build and the export of a file. Comfortably above a sub-4-GB-dictionary file’s decompressed dictionary (those export in a single pass at today’s speed), and far under a large VM’s RAM so a 50-GB-class file is bounded rather than OOM. Seesplit_memory_budget. - DEFAULT_
TILE_ BUDGET - Default per-tile byte budget
T(SPEC.md §7.1). - ENGINE_
VERSION - The
rete-coreversion this facade re-exports. - HEADER_
LEN - Fixed header size in bytes.
- MAGIC
- Magic bytes at offset 0: ASCII
RETE. - MAX_
LOUVAIN_ PASSES - Most local-moving passes one Louvain level may make before it stops and returns the partition it has.
- MIN_
STABLE_ READ_ VERSION - Oldest stable format generation accepted by this reader.
- POLYGLOT_
DIGITS - Fixed decimal width of the offset that follows
POLYGLOT_MARKER. - POLYGLOT_
MARKER - The marker a polyglot (HTML +
.rete) file carries in its first bytes so a reader can locate the embedded.retewithout knowing the file size: ASCIIRETE-BASE:followed byPOLYGLOT_DIGITSzero-padded decimal digits — the byte offset where the.retebegins. It is emitted inside an HTML comment so browsers ignore it, and it sits within the first header window a reader fetches. - RDF_
TYPE rdf:type— the predicate that assigns a class to a resource.- REASON_
RULESET - Version tag of this reasoner’s rule set. Stamped into a baked coherence card so
a
coherent: truecan never be misread as a guarantee from a different set of rules. Bump this whenevermaterialize/detect_inconsistencieschanges (a rule added/removed/altered), sorete reason --verify-cardrejects a stale stamp. - VERSION
- The engine version, as published on crates.io.
Traits§
- Graph
View - A read-only view of the data graph for SHACL validation. The validator only
ever asks targeted questions — a focus node’s values, the subjects of a
predicate, the instances of a class — so this surface is small enough to back
two ways: an in-memory triple set (
DataGraph, eager) or a.retefile’s index directly (ReteGraph), which routes each lookup as a range read so a remote validation faults only the tiles holding the shapes’ targets, not the whole graph. The class/instance helpers are derived from the primitives, so a backend only implements the six lookups. - Range
Reader - Something that can serve arbitrary byte ranges of a
.reteresource. - Service
Client - Executes one SPARQL query against a remote endpoint (the SPARQL Protocol)
and returns its solutions. Implementations own transport, auth, and
timeouts; they typically
POSTthe query withAccept: application/sparql-results+jsonand feed the body throughparse_sparql_json_results. Errors are strings, surfaced verbatim as the query error (or, underSERVICE SILENT, swallowed per the spec) — name the endpoint in the message, the engine adds no prefix.
Functions§
- 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. - auto_
block - Pick a
BlockCacheReaderblock size from the file length: bigger files get bigger blocks so a remote query makes far fewer (but larger) round trips — 128 KiB ≤ 10 MB, 256 KiB ≤ 100 MB, 512 KiB above. The over-fetch is modest next to the round-trip latency it saves on a high-latency link (S3/CDN). Shared by the CLI and the wasm client so both size identically; the file length is known for free from the openingHEAD/Content-Range. - batch_
reach_ serial - Per-seed transitive reach, serial loop (reference). Results are returned in
seed order. The parallel sibling
crate::parallel::batch_reach_parallelproduces an identical result. - build_
adjacency - Forward adjacency in unified node space for one predicate:
node -> [succ]. Built once and shared (read-only) across all seeds. For reverse reachability (“who reaches the seed?”), build the map yourself fromRete::predicate_pairsswapping(s, o) -> (o, s). - build_
dendrogram - Build the full dendrogram by repeated Louvain + coarsening, stopping when a round no longer compresses the graph (or only one node remains).
- build_
pyramid_ meta - Build the encoded pyramid-meta section for a graph: cluster, pick a round
sized to
budget, then emit the summary (quotient) graph. Returns(encoded_meta, pyramid_levels). - build_
pyramid_ meta_ algo - Like
build_pyramid_meta_with, but selects the communityPyramidAlgo.PyramidAlgo::Typespartitions byrdf:type— the deterministic, parallelizable alternative to Louvain (one linear pass, no modularity) that still emits the full summary +query_stats; it falls back to Louvain when the graph has no usable typing. Everything downstream of the dendrogram (round choice, summary, schema pyramid, planner stats) is shared across algorithms. - build_
pyramid_ meta_ with - Like
build_pyramid_meta, buttype_overrideforces the schema-pyramid’s type predicate (e.g.wdt:P31) instead of auto-detection. Uses the defaultPyramidAlgo::Louvaincommunity algorithm — byte-identical to before. - build_
schema_ pyramid - Compute the schema pyramid for a graph at the materialized
round, auto-picking the type predicate. Empty when the graph has no usable typing. - choose_
round_ for_ budget - The coarsest round whose every tile fits
budget_bytes, else round 0. Coarser rounds mean fewer, larger tiles; we want the fewest tiles that still respect the per-tile budget (PMTiles-style). - detect_
polyglot_ base - If
head(the first bytes of a resource whose byte 0 is NOT theRETEmagic) carries aPOLYGLOT_MARKER, return the byte offset of the embedded.rete. - eval_
bgp - Evaluate a BGP against the file’s default graph, returning all solutions resolved to terms (the public convenience API).
- eval_
query - Evaluate any supported SPARQL query form (SELECT / ASK / CONSTRUCT).
- eval_
query_ reasoned - Like
eval_query, but with OWL 2 QL entailment on: the lowered plan is rewritten by the internal QL lowering pass so the answer includes ontology-entailed solutions (Stage 1a:rdfs:subClassOf), computed over the raw data with no materialization. Opt-in — a plaineval_queryis byte-identical to before. - eval_
query_ with eval_querywith explicitQueryOpts— the single entry point the opt-in toggles (🧠 reasoning, union default graph) funnel through.- eval_
query_ with_ warnings eval_query_with, plus the diagnostics the evaluation produced.- eval_
select_ communities - Evaluate a SELECT per pyramid community, then merge: each community’s
subjects are pushed into the plan as a VALUES binding, the partial rows
are concatenated, and the solution modifiers (GROUP BY / ORDER BY / LIMIT
/ DISTINCT) run once on the union — so the rows are identical to
eval_query’s answer. Sound only for subject-star queries over the default graph (every triple pattern sharing one subject variable; FILTERs allowed); anything else returnsSparqlError::Unsupportedrather than a possibly-wrong split answer.roundpicks the dendrogram granularity (None= the build’s tile-budget round). Also returns each community’s subject and row counts for display. - eval_
sparql - Parse and evaluate a SELECT against a file, applying the plan then
projection, DISTINCT, OFFSET, and LIMIT. Returns
(projected_vars, solutions). - eval_
sparql_ reasoned - Like
eval_sparql, but with OWL 2 QL entailment on (seeeval_query_reasoned). - iri_
content_ defect - Classify the content of an
IRIREF— what sits between<and>— returningNonewhen it is a valid absolute IRI, and otherwise the class that says what can be done about it. - louvain_
one_ level - One level of Louvain local-moving modularity optimization.
- louvain_
one_ level_ stats louvain_one_level, also returning how many passes it made and whether it stopped atMAX_LOUVAIN_PASSES.- parse_
select - Parse a SPARQL
SELECTquery and lower it to aSelect. - parse_
sparql_ json_ results - Parse a SPARQL 1.1 Query Results JSON document (
application/sparql-results+json) into bindings of variable → N-Triples term token. An ASK document (noresults) yields no bindings. Unknown per-binding fields are ignored;xsd:stringdatatypes are dropped (a simple literal — matching how plain literals are tokenized everywhere else in the engine). - 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. - project_
graph - Project RDF integer triples onto the undirected node graph the pyramid
clusters: one node per distinct term (via the dictionary’s unified node
space), one unit-weight edge per
(subject, object)pair (predicates are ignored for clustering; parallel edges accumulate weight). - push_
json_ string - Append
vtooutas a JSON string literal (RFC 8259 escaping): the mandatory escapes (",\, and C0 controls, the common ones in short form), every other char — including all UTF-8 — passed through. Matches whatserde_jsonemits for a string by default. - query_
predicates - Collect the concrete predicate IRIs a query constrains on — i.e. every
IRI that appears in the predicate position of a triple pattern, or as a plain
predicate inside a property path. Variable predicates (
?p) and the speciala(rdf:type) keyword are normalized to their IRI tokens (<…>). - reach_
one - Transitive reach of
seedover the adjacency (excludes the seed itself). Plain BFS; deterministicBTreeSetresult. This is the single shared BFS used by both the serial and parallel batch drivers. - 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. - read_
card_ and_ build_ info_ ranged - Fetch the metadata (Dataset Card) and build-info sections via a
RangeReaderin the fewest requests: the 1 KiB header, then — because the writer lays the build-info section immediately after the metadata — one coalesced range covering both. A file with only one of the two costs the same two requests; a file with neither costs just the header read. This keeps “card + build conditions” within the CARD tier’s 1 header + 1 range budget instead of adding a third request. - read_
card_ and_ build_ info_ with_ header read_card_and_build_info_ranged, also returning the parsedHeaderit had to read anyway.- read_
metadata_ ranged - Fetch only the metadata section (the opaque Dataset Card blob) via a
RangeReader: read the 1 KiB header, then the metadata byte range — nothing else. This is the index-free CARD tier of the exploration model: a remote/S3 client learns the dataset’s self-description in two small range requests, never touching the dictionary, index, or pyramid. ReturnsNonewhen the file carries no metadata. - read_
schema_ coherence_ ranged - Dictionary-free Tier-0 coherence read. Fetch only the header and the
pyramid-meta range (2 small range reads) and run
schema_coherenceover the schema pyramid — never touching the dictionary (which a literal-heavy file makes large) or the triple index.Ok(None)if the file ships no pyramid. - read_
schema_ summary_ ranged - The schema summary (per-class histogram + class relations at the finest
level) read over a
RangeReaderfrom the schema pyramid alone — the index-free, range-readable source for a Schema view of a remote graph. Returns(classes, relations)withclasses = [(class_iri, count)]andrelations = [(s_class, predicate, o_class, count)];Nonewhen the file has no schema pyramid. Likeread_schema_coherence_ranged, it reads only the trailing schema block, so it stays flat at any graph size. - read_
text_ index_ token_ table_ len_ ranged - Byte length of the TEXT_INDEX section’s leading token table, from a
header a caller has already parsed — the prefix range a first
Rete::text_searchfetches, and the honest figure to quote as its cost (header.text_index_lencounts the postings blob too and overstates it several-fold).Nonewhen the file carries no text index, or its first bytes could not be read. - reason
- Forward-chain the supported RDFS/OWL rules to a fixpoint, then scan for
inconsistencies over the closed graph.
inferredexcludes triples already present inbase_triples. - 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.
- results_
envelope_ json - Serialize
outas{ "kind": …, … }.extrais a raw JSON fragment of additional object members appended before the closing brace (e.g.,"remote":{…}); pass""for none.CONSTRUCTis rendered as atriplesarray — the text formats (Turtle / JSON-LD) are handled by the caller, which owns those serializers. - routed_
triple_ pattern - Classify queries whose graph access is exactly one default-graph triple pattern. Solution modifiers (projection, LIMIT, aggregate wrappers) do not change the underlying range access, but named graphs, FROM, joins, filters, paths, and other algebra need the full SPARQL evaluator.
- sanitize_
iri_ content - Percent-encode the offending characters of an
IRIREF’s content. - sanitize_
term - Percent-encode every repairable IRI inside a canonical term token, returning
Nonewhen nothing changed. The token-level counterpart ofsanitize_iri_content; it rebuilds quoted triples and literal datatypes around the repaired IRI so the result is still a canonical token. - schema_
classes - Class populations: the number of resources of each
rdf:typeclass in the default graph, descending by count. The instance-count companion toschema_summary. - schema_
coherence - Compute T-Box coherence points from the schema-pyramid fields alone — no
dictionary, no index, no instance data. Shared by
SummaryView::tbox_coherenceand the dictionary-freeread_schema_coherence_ranged. Emitssubclass-cycleandunsatisfiable-class(a class whose ancestor closure — over all parents, folded throughowl:equivalentClass— contains both ends of a disjoint pair). - schema_
summary - An ontology-aware coarse graph: instead of structural communities, group
entities by their
rdf:typeclass and aggregate relations between classes. Returns(subject_class, predicate, object_class, count)over the default graph. Entities with no type are(untyped); literals are(literal).rdf:typetriples themselves define the classes and are not counted as relations. This is the dataset’s effective schema with instance volumes. - sparql_
json_ ask - Serialize an ASK result as a SPARQL 1.1 Query Results JSON document.
- sparql_
json_ results - Serialize a SELECT result as a SPARQL 1.1 Query Results JSON document.
varsfixes theheadorder (pass the projection); solutions’ bindings are term tokens exactly as the engine returns them. - split_
memory_ budget - Split a total byte budget across the block cache, the dictionary chunk cache
and the index tile cache (bounded-export phase 2, plan §5.2).
u64::MAX(unlimited, e.g.--in-memoryor--memory-budget-mb 0) passes straight through to every consumer. - summarize
- Aggregate triples into the quotient (summary) graph at
round. - summary_
query_ shape - Classify SPARQL queries that can be answered exactly from the pyramid summary’s per-predicate totals. This is intentionally conservative: anything with constants, repeated variables, filters, joins, paths, named graphs, ORDER BY, OFFSET/LIMIT, or non-summary-safe aggregates still requires the index. The only accepted DISTINCT shape is a predicate list over one fully unbound triple pattern.
- term_
defect - Classify a canonical N-Triples term token —
<iri>,_:b,"lit","lit"^^<dt>,"lit"@en, or an RDF-star<<s p o>>— returning the first IRI defect it carries, orNone. - tile_
by_ community - Partition triples into per-community tiles at
round, ordered by community. - tokenize
- Split text into index/query tokens: Unicode-alphanumeric runs, lowercased,
length ≥
MIN_TOKEN_LEN. The build and query sides MUST use this same function so a query word matches how it was indexed. - validate_
shacl - Validate
dataagainstshapes.datais anyGraphView— an in-memoryDataGraph(eager) or aReteGraphthat routes lookups as range reads (lazy / remote, fetching only the shapes’ targets). - verify
- Recompute the content hash from a file image and check it against the header — detects corruption or truncation of the payload sections.
- warnings_
json - The warnings as a JSON array (
[]when empty), in the field order ofQueryWarningwithargKindforkind. - write_
dataset - Serialize a full RDF dataset: the default-graph index plus zero or more
named graphs
(iri, index), all sharing one dictionary. - write_
dataset_ with_ metadata - Serialize a dataset with an opaque metadata payload occupying the file’s
metadata section (the application layer defines its meaning — the CLI stores a
JSON Dataset Card there). The section sits immediately after the header and
before the dictionary, so
metadata_offsetstays atHEADER_LENand every downstream section shifts bymetadata.len(). The payload is folded into thecontent_hash, soverifycovers it and it is tamper-evident. - write_
file - Serialize a complete
.retefile image from a dictionary, index, and an (optionally empty) encoded pyramid-meta section.pyramid_levelsrecords the number of dendrogram rounds the pyramid spans (0 if no pyramid).
Type Aliases§
- Binding
- A solution: variable name → bound term (the public, resolved form).
- Community
Select - The outcome of a community-split SELECT: the projected variables, the merged solution rows, and each community’s contribution.
- NodeId
- A dictionary id in the unified node space — the single id space that covers every term that ever appears as a subject or an object. This is the id reachability, the community pyramid, and the graph index work in.
- Object
Id - A dictionary id in the object id space (terms seen in object position).
Map to a
NodeIdwithDictionary::object_node. - Pattern
- A triple pattern:
Noneis an unbound variable,Some(id)a bound term. - Predicate
Id - A dictionary id in the predicate id space. Predicates have their own dense id space and are never part of the unified node space.
- Subject
Id - A dictionary id in the subject id space (terms seen in subject
position). Map to a
NodeIdwithDictionary::subject_node. - Term
Token - The textual form of an RDF term as stored in the dictionary and emitted in
N-Triples: an IRI (
<…>), a blank node (_:…), or a literal ("…", optionally with an@langor^^<datatype>suffix). An alias forstr; it names intent at API boundaries that take a term rather than arbitrary text. - Term
Triple - A resolved triple as terms.
- Triple
- A triple of dictionary IDs in some permutation’s component order.