Skip to main content

Module compact

Module compact 

Source
Expand description

Compact, lossless encoding of an EvidenceRun.

Full evidence is large for three measured reasons, and they dominate on different corpora:

  • Repeated terms. The same IRIs recur at every mention. On brick/models/bldg1.ttl (2,650 triples) 243,249 term occurrences are 548 distinct terms — a 444× redundancy, and the single largest lever. It grows with the corpus: bldg11.ttl reaches 998×.
  • Repeated subtrees. The same (constraint, node) conclusion is reached through many parents, and each occurrence is written out in full. On the same model 105,673 evidence-node occurrences are 19,765 distinct nodes — 5.3×, and roughly constant across the Brick corpus.
  • The constraint catalog. Both arenas are dumped on every run regardless of how many findings there are. On a small 223P model (guideline36-2021-A-1.ttl, 146 triples) that fixed cost is 2.02 MB of a 3.52 MB run — 57%.

Together, on bldg1.ttl, a 33.1 MB run encodes to 9.8 MB with its catalog and 7.6 MB without. sharing reports the two redundancy factors for a run directly, measured against the very predicates the encoder interns by, so a quoted ratio cannot drift from what compaction actually collapses.

This encoding removes both without losing anything: evidence nodes and RDF terms are hash-consed into tables and referenced by index, and the catalog is optional for callers that already hold the schema. expand reconstructs the original run exactly.

The encoding is structural rather than typed: it interns any tagged {"type", "details"} object and any RDF term, so it follows the evidence vocabulary automatically instead of mirroring every variant. That keeps one definition of the evidence types and gives the Python bindings the same format for free.

Structs§

Sharing
How often the interned entries of a run repeat.

Enums§

CompactError
Why a compact encoding could not be read back.

Functions§

compact
Encode run in the compact form.
compact_value
Encode an already-serialized run.
expand
Reconstruct a run from its compact encoding, which must carry its catalog.
expand_value
Reconstruct the serialized run without decoding it into the typed form.
expand_with_catalog
Reconstruct a run whose catalog was omitted, using a catalog held elsewhere.
sharing
Measure how much a run’s evidence repeats, without keeping the encoding.
to_compact_json
Serialize the compact encoding.