pub struct GitIndexBuilder { /* private fields */ }Expand description
Accumulates objects and emits the reserved sections.
Implementations§
Source§impl GitIndexBuilder
impl GitIndexBuilder
pub fn new(hash: GitHashKind) -> Self
Sourcepub fn pack_tier(hash: GitHashKind) -> Self
pub fn pack_tier(hash: GitHashKind) -> Self
A builder for a pack-tier archive: one whose data entries are
pack-<id>.pack / pack-<id>.idx rather than one entry per object.
This is what gunnar’s repack() seals. The reasoning is not znippy’s to
re-argue but is worth stating, because it decides what this builder must
not emit: a git object inside a pack is already deflated and often a
delta, so a tier that stores inflated content per oid pays a full
inflate-plus-deflate round trip on every fetch, for ever, and can never
be pack-copied. Measured on gunnar’s own fixture, a znippy archive of
60000 small git objects came out 3.4× larger than its input — the
tier inflated rather than compressed.
So the three derived sections are not emitted:
__gunnar_oid__— the pack’s.idxis the oid index, and a far better one: it addresses pack offsets, which is what a reader needs.__gunnar_graph__/__gunnar_reach__— derived from object payloads this builder never sees.
They are omitted rather than emitted empty. An empty __gunnar_oid__
beside a pack holding a million objects is not a smaller truth, it is a
false one, and GitOidIndex::open returning
None is the state a consumer can act on.
with_section still works and is the point: refs
and secrets are sealed the same way, through this one composition point,
whichever tier the archive holds (LAW 5).
Sourcepub fn is_pack_tier(&self) -> bool
pub fn is_pack_tier(&self) -> bool
True when this builder seals a pack tier rather than loose objects.
Sourcepub fn with_section(self, section: ReservedSection) -> Result<Self>
pub fn with_section(self, section: ReservedSection) -> Result<Self>
Seal an already-built reserved section — the __gunnar_refs__ or
__gunnar_secrets__ push log — alongside the object sections.
Refused unless the module is reserved: a section the manifest readers do
not classify as reserved is merged into the data index, which silently
corrupts list, decompress and the iceberg sink. Catching it here
names the offending module, instead of surfacing later as a wrong file
count.
pub fn with_reach_policy(self, policy: ReachPolicy) -> Self
Sourcepub fn without_reach(self) -> Self
pub fn without_reach(self) -> Self
Do not emit __gunnar_reach__. Use when the bitmaps’ build cost is not
wanted for this repack.
pub fn hash_kind(&self) -> GitHashKind
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn push_canonical(&mut self, canonical_bytes: &[u8]) -> Result<String>
pub fn push_canonical(&mut self, canonical_bytes: &[u8]) -> Result<String>
Add one object from its canonical bytes. Returns the oid hex — which is
also the relative_path the archive must store the object under.
Sourcepub fn extend_canonical<'a, I: IntoIterator<Item = &'a [u8]>>(
&mut self,
objects: I,
) -> Result<Vec<String>>
pub fn extend_canonical<'a, I: IntoIterator<Item = &'a [u8]>>( &mut self, objects: I, ) -> Result<Vec<String>>
Add many objects at once.
Sourcepub fn build_sections(
&self,
first_row: &HashMap<&str, u64>,
) -> Result<Vec<ReservedSection>>
pub fn build_sections( &self, first_row: &HashMap<&str, u64>, ) -> Result<Vec<ReservedSection>>
Build the sections against an explicit path → first-lookup-row mapping.
Separated from into_reserved_builder so
it is testable without sealing an archive, and so the sink path and the
direct path are the same code (LAW 5).
Sourcepub fn finish_sections(
self,
first_row: &HashMap<&str, u64>,
) -> Result<Vec<ReservedSection>>
pub fn finish_sections( self, first_row: &HashMap<&str, u64>, ) -> Result<Vec<ReservedSection>>
Every reserved section this archive will carry: the object sections from
build_sections, then the caller’s push logs.
The one composition point. Both the direct path and the sink path go through it, so a section added here cannot reach one and miss the other.
Sourcepub fn into_reserved_builder(self) -> ReservedSectionBuilder
pub fn into_reserved_builder(self) -> ReservedSectionBuilder
Hand the builder to ArrowIpcSink::with_reserved_builder.
The closure runs at seal time with the sink’s final sorted lookup, so
__gunnar_oid__ points at the rows the archive actually has. It fails
loudly — rather than emitting a silently wrong index — if an object it
was given is not present in the archive as a relative_path.