Skip to main content

GitIndexBuilder

Struct GitIndexBuilder 

Source
pub struct GitIndexBuilder { /* private fields */ }
Expand description

Accumulates objects and emits the reserved sections.

Implementations§

Source§

impl GitIndexBuilder

Source

pub fn new(hash: GitHashKind) -> Self

Source

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 .idx is 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).

Source

pub fn is_pack_tier(&self) -> bool

True when this builder seals a pack tier rather than loose objects.

Source

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.

Source

pub fn with_reach_policy(self, policy: ReachPolicy) -> Self

Source

pub fn without_reach(self) -> Self

Do not emit __gunnar_reach__. Use when the bitmaps’ build cost is not wanted for this repack.

Source

pub fn hash_kind(&self) -> GitHashKind

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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.

Source

pub fn extend_canonical<'a, I: IntoIterator<Item = &'a [u8]>>( &mut self, objects: I, ) -> Result<Vec<String>>

Add many objects at once.

Source

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).

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.