Skip to content

content_copyCarve rocket_launch

Cut a query-defined slice out of a large source graph into a fresh, small graph — so Reason and Validate run over a graph sized to your hardware instead of the whole source.

Roadmap — not shipped in v0.6.14

Carve is the headline of the carving line on the Roadmap: C1 — carve by query (v0.6.15) and C2 — re-encode into a fresh small dictionary (v0.6.16). The one-call carve_graph verb is the target; it is not yet a shipped UDF. The manual approximation below works on v0.6.14 today.

What it will do

Carve resolves a SPARQL query into the set of quads it touches, copies just those quads into a new graph_id, and re-encodes them against a fresh, small dictionary (C2) so the working set shrinks from the full source dictionary to just the slice. The carved graph is then Sealed with its own hexastore and is small enough to reason over on ordinary hardware.

The manual approximation today (v0.6.14)

Until the one-call verb ships, you can approximate Carve with shipped primitives: select the slice with pgrdf.construct, write it out, and reload it into a fresh graph with the staged loader:

sql
-- 1. CONSTRUCT the slice you need to reason over
SELECT pgrdf.construct(
  'PREFIX ex: <http://example.com/>
   CONSTRUCT { ?s ?p ?o }
   WHERE { ex:SoftwareEngineering (ex:related|^ex:related){1,2} ?s . ?s ?p ?o }');

-- 2. reload that slice into a fresh graph (its own small dictionary)
SELECT pgrdf.add_graph(900);
SELECT pgrdf.load_turtle_staged_run('/tmp/slice.nt', 900, 0);

The shipped verb will fold those steps into one call and re-encode in place — see C1/C2 on the roadmap.

Where it will sit in a chain

After Import + Seal of the full graph; before Unload and Reason. Carve is the pivot of the scale-meets-hardware pattern.

See also

MIT licensed. Documentation for pgRDF — built with VitePress, served via GitHub Pages.