Skip to main content

GitOidIndex

Struct GitOidIndex 

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

Reader over a __gunnar_oid__ section.

Implementations§

Source§

impl GitOidIndex

Source

pub fn parse(bytes: Vec<u8>) -> Result<Self>

Parse a section produced by build_section.

The header width comes out of the section’s own header_len. Whether the bytes are re-homed into a 64-aligned allocation does not — that is a property of this reader’s heap, not of the bytes, and it is not recorded anywhere. parse infers it: a 64-byte header exists only to put the keyspace on a line boundary, which an arbitrary base would undo, so a header_len of 64 implies the aligned allocation. See parse_as for the third arm, whose whole point is that the two are separable.

Source

pub fn parse_as(bytes: Vec<u8>, layout: OidLayout) -> Result<Self>

parse with the reader’s allocation choice forced to layout’s, and the section’s own header width checked against it.

This exists for OidLayout::Compact64Alloc, which is a 24-byte header over a 64-aligned base — indistinguishable on disk from OidLayout::Compact, because the difference is in the heap. It is the control arm of the alignment experiment: it holds the allocator fixed and moves only the header offset.

Source

pub fn layout(&self) -> OidLayout

The layout this section was written in.

Source

pub fn keyspace_phase(&self) -> usize

Base address of the stree keyspace, modulo the cache line.

This is the whole variable of the alignment experiment, exposed so a guard can assert the arm it thinks it built is the arm it got — a timing difference between two arms that turned out to share a phase would be noise wearing a conclusion’s clothes.

Source

pub fn open(archive: &Path) -> Result<Option<Self>>

Read the section out of a sealed archive. Ok(None) when the archive carries no oid index (i.e. it is not a git-format archive).

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn hash_kind(&self) -> GitHashKind

Source

pub fn key_at(&self, i: usize) -> i64

The key of entry i.

Source

pub fn oid_at(&self, i: usize) -> &[u8]

The full oid of entry i.

Source

pub fn candidate_run(&self, key: i64) -> Range<usize>

The unverified candidate run for a key: every entry sharing that 8-byte prefix, as start..end. Normally length 1; length > 1 is a real prefix collision.

Exposed so a test can assert that a collision actually produces a run of two and that the verify step is what tells the two oids apart. A caller resolving an oid should use lookup, never this.

Source

pub fn lookup(&self, oid: &[u8]) -> Option<OidHit>

Resolve a raw oid. None when absent.

stree narrows to a candidate run; the full oid is then compared against every candidate. Skipping that comparison would return a different object’s row whenever two oids share their first eight bytes.

Source

pub fn lookup_hex(&self, hex_oid: &str) -> Option<OidHit>

Resolve a hex oid.

Source

pub fn lookup_batch(&self, oids: &[&[u8]]) -> Vec<Option<OidHit>>

Resolve many oids at once through stree’s software-pipelined batch traversal. This is the path that matters: serving one pack is hundreds to thousands of lookups, and the pipelined walk overlaps their memory latency instead of paying it serially.

Results are positional — out[i] corresponds to oids[i]. Every hit is full-oid verified, exactly as in lookup.

Source

pub fn lookup_batch_hex(&self, hex_oids: &[&str]) -> Vec<Option<OidHit>>

Hex convenience over lookup_batch.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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.