Skip to main content

Module chunk

Module chunk 

Source
Expand description

Content-defined chunking of the manifest’s key stream (docs/plans/flint-lean-chunked-manifest-design.md §3).

The pointer layout made a TAKEOVER cheap; it did nothing for a publish, which still writes every entry of the project to change one file. Splitting the sorted key stream into immutable, content- addressed chunks makes a publish rewrite only what it touched.

Everything here is pure and synchronous on purpose: the boundary rule is part of the on-the-wire format, and a format decision that can only be exercised through a store is one nobody tests properly.

Structs§

ChunkBody
A chunk object’s body.
ChunkRef
One entry of the pointer’s chunk list.

Constants§

CHUNK_MAX
Ceiling, so one pathological run cannot recreate the single-object problem this exists to remove.
CHUNK_MIN
Floor. Hash boundaries are geometrically distributed, so without one a project accumulates many tiny objects.
CHUNK_TARGET
Entries per chunk, in expectation. ~1 MiB of compact JSON at the ~277 B/entry this manifest measures: big enough that per-object overhead is noise, small enough that one changed file rewrites ~1 MiB rather than the whole project.

Functions§

assemble
Rebuild the entry map from a chunk list and the fetched bodies.
chunk_address
The content address of a chunk body: SHA-256, truncated to 128 bits.
chunk_ranges
The shipped sizing.
chunk_ranges_with
Split a SORTED key stream into content-defined runs, as end-exclusive indices. [] for no keys; the last run always ends at keys.len().
split
split_with
Split entries into chunk bodies and their references.