Module tree

Module tree 

Source
Expand description

Trees: the manifest of one version, mapping key -> node address.

This is where the entity key lives, and it is the whole of the GUID-agnostic design. A node address is its content (crate::node); the key that names it is here. So a from-scratch re-export that regenerates every GlobalId rewrites tree keys and leaves every node address untouched — the version reads as unchanged content under a key remapping, which is the rename case @ifc-lite/diff’s content-matching tiers resolve for one-to-one matches. They deliberately abstain where a match is not one-to-one — a group of re-GUIDed coincident duplicates yields no remapping at all — which is the same open case as relationship endpoints under deduplication (crate::node::Node::Relationship).

§Chunking

A real delivery is hundreds of thousands of entities. A monolithic manifest would be rewritten in full for a two-element change, so the manifest is split into content-addressed chunks and a tree is the list of chunk addresses; unchanged chunks are reused by reference between commits.

Boundaries are content-derived, not positional. With fixed-size chunks, inserting one entity shifts every subsequent entry and invalidates every chunk after the insertion point. With a boundary chosen from the content itself, an insertion disturbs one chunk. This is the packfile problem git already solved; the design is reused, the code is not — git is GPL-2.0 and cannot enter an MPL-2.0 tree (see the spec set, index §6.2).

Structs§

Tree
A version’s manifest: ordered chunk addresses.
TreeChunk
A run of entries, content-addressed so an unchanged run is reused.
TreeEntry
One entry: an entity key, the node carrying its content, and its class.

Constants§

CHUNK_MAGIC
Magic announcing the tree-chunk format.
TARGET_CHUNK_ENTRIES
Target entries per chunk. Boundaries are content-derived, so this is an average rather than a cap — see the is_boundary predicate below.
TREE_FORMAT_VERSION
Format version within both magics.
TREE_MAGIC
Magic announcing the tree format.

Functions§

build_tree
Build a tree from entries, chunking on content-derived boundaries.
build_tree_with_target
build_tree with an explicit chunk target, for tests that need small chunks without a hundred thousand entries.