Expand description
Stable byte-range and lazy-open API for local or remote .rete files.
Structs§
- Block
Cache Reader - Byte
Range - A byte range in the
.retefile image. - 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). - 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. - 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. - Search
View - A
.reteopened for search only: the dictionary’s chunk directories, and the TEXT_INDEX / pyramid deferred behind their lazy slots. Nothing else. - 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.
Constants§
- 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.
- 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.
Traits§
- Range
Reader - Something that can serve arbitrary byte ranges of a
.reteresource.
Functions§
- 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. - 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. - 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.