Build a persistent on-disk store once, then query it without loading into RAM

July 5, 2026 · View on GitHub

sparq

CI License: MIT Benchmarks dashboard MSRV 1.88 Status: experimental

sparq is a lightning-fast RDF triplestore and SPARQL 1.1 / 1.2 engine, written in Rust — usable as a library, CLI, HTTP server, and from Python and JavaScript/WASM.

Status: experimental research engine. The API is unstable and pre-1.0. Conformance against the W3C SPARQL, SHACL, and inference suites is tracked by CI ratchets that only ever go up — generated by sparq-conformance and published on every run (inference floor committed at inference-conformance-report.md). SPARQL SERVICE federation ships behind the opt-in service cargo feature (off in the default build); when built in it is default-DENY-all egress, allowlisted per host as an SSRF guard (see crates/sparq-server/README.md and research/roadmap.md).

🚀 Quickstart

cargo build --release

# Query a file (Turtle / N-Triples / N-Quads / TriG, optionally .gz / .bz2 / .zst)
cargo run --release -p sparq-cli -- query data.ttl turtle \
  'SELECT ?s ?o WHERE { ?s <http://schema.org/name> ?o } LIMIT 10'

# Build a persistent on-disk store once, then query it without loading into RAM
cargo run --release -p sparq-cli -- build data.nt ntriples ./idx
cargo run --release -p sparq-cli -- query-mmap ./idx 'SELECT (COUNT(*) AS ?n) WHERE { ?s ?p ?o }'

# W3C SPARQL Protocol HTTP server on :3030
cargo run --release -p sparq-server -- --addr 127.0.0.1:3030 --format turtle data.ttl

As a library:

use sparq_core::Graph;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let turtle = r#"<http://example.org/alice> a <http://schema.org/Person> ."#;
    let g = Graph::load_str(turtle, "turtle")?;
    let _rows = sparq_engine::query(&g, "SELECT ?s WHERE { ?s a <http://schema.org/Person> }")?;
    let _json = sparq_engine::query_json(&g, "SELECT (COUNT(*) AS ?n) WHERE { ?s ?p ?o }")?;
    Ok(())
}

The CLI, HTTP server, Python (sparq-rdf on PyPI — import sparq), and JS/WASM (@jeswr/sparq) mirror the same surface. Per-surface how-tos live in the usage skills.

✨ Features

The engine core is always built; every other capability is an opt-in crate that the core does not depend on (so it stays lean — enforced in CI). Each capability links its how-to and the standard it implements.

  • SPARQL query — run SPARQL 1.1 and 1.2 over your data (guide).
  • SPARQL Update — insert, delete, and load data with SPARQL 1.1 Update (guide).
  • RDF parsing & ingest — load and parse Turtle, N-Triples, N-Quads, and TriG, with transparent .gz / .bz2 / .zst decompression (guide).
  • RDF 1.2 triple terms — store and query triple terms per RDF 1.2 Concepts (guide).
  • Custom extension functions — register your own Rust functions under IRIs and call them in SPARQL (docs/extension-functions.md).
  • RDFS / OWL-RL / N3 reasoning — materialise entailments under RDFS, the OWL 2 RL profile, and Notation3 (guide).
  • SHACL validation — validate graphs against shapes with SHACL (guide).
  • Full-text search — index and search RDF literals from SPARQL (guide).
  • GeoSPARQL — spatial filters and functions over geometries with OGC GeoSPARQL (guide).
  • Vector & similarity search — embedding-based nearest-neighbour and structural similarity over entities (guide).
  • Natural-language & GenAI retrieval — schema introspection and grounded NL→SPARQL for LLM agents (guide).
  • HDT archives — load compressed HDT datasets (crate).
  • RDF stream processing — continuous windowed queries with RSP-QL (guide).
  • Solid access control — enforce Solid WAC and ACP authorisation (crate).
  • RDF Dataset Canonicalization — deterministic, blank-node-relabelled canonical form for hashing/signing/diffing with RDFC-1.0 (guide).
  • Zero-knowledge query proofs (research scaffold — NOT yet sound) — model proving a query result is correct without revealing the data (guide). The v1 verifier provides no soundness guarantee to a relying party pending external audit — see the security caveat.
  • Federated MPC (research scaffold — no security guarantee yet) — model evaluating SPARQL across parties with multi-party computation (guide); honest-majority semi-honest, not maliciously secure (SECURITY.md).

Agent skills — how to use sparq from Claude Code and other AI agents — are in the usage-skills router.

See AGENTS.md for the full crate map and what each one does.

📚 Learn more

  • Use itAGENTS.md (start here), then skills/SKILL.md, the router pointing at the per-surface usage skill (Rust, CLI, HTTP, Python, JS/WASM, plus reasoning, SHACL, full-text, vector, GeoSPARQL, RSP-QL, ZK query proofs). In Claude Code: /plugin marketplace add jeswr/sparq then /plugin install sparq@sparq-tools.
  • Designresearch/ARCHITECTURE.md (blueprint), research/roadmap.md and its completion audit. The research/ tree holds the design notes and measured verdicts for the engine internals.
  • Performance — numbers are not baked into the docs (they drift). Live per-commit metrics are at the benchmarks dashboard; the registry and exact invocations are in bench/benchmarks.toml and bench/CATALOG.md. The QLever comparison methodology is in bench/qlever-baselines.md and the continuous Oxigraph differential harness in research/BENCHMARKS.md.
  • Trust itASSURANCE.md: the 15-minute walkthrough of the assurance estate (conformance ratchets, independent oracles, fuzzing, bounded proofs, honesty gates) — how to check sparq works as claimed without reading the codebase.
  • ContributeCONTRIBUTING.md (the build/test/lint gate, the conformance ratchets, and the crate-README conventions) and SECURITY.md.

Note (crates.io installs): builds installed from crates.io (e.g. cargo install sparq-cli) resolve the upstream spargebra parser — the vendored SPARQL-parser conformance fixes (vendor/spargebra/SPARQ-PATCHES.md) apply only to git builds until the upstream PRs land.

License

MIT.