pub struct GitOidIndex { /* private fields */ }Expand description
Reader over a __gunnar_oid__ section.
Implementations§
Source§impl GitOidIndex
impl GitOidIndex
Sourcepub fn parse(bytes: Vec<u8>) -> Result<Self>
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.
Sourcepub fn parse_as(bytes: Vec<u8>, layout: OidLayout) -> Result<Self>
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.
Sourcepub fn keyspace_phase(&self) -> usize
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.
Sourcepub fn open(archive: &Path) -> Result<Option<Self>>
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).
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn hash_kind(&self) -> GitHashKind
Sourcepub fn candidate_run(&self, key: i64) -> Range<usize> ⓘ
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.
Sourcepub fn lookup(&self, oid: &[u8]) -> Option<OidHit>
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.
Sourcepub fn lookup_hex(&self, hex_oid: &str) -> Option<OidHit>
pub fn lookup_hex(&self, hex_oid: &str) -> Option<OidHit>
Resolve a hex oid.
Sourcepub fn lookup_batch(&self, oids: &[&[u8]]) -> Vec<Option<OidHit>>
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.
Sourcepub fn lookup_batch_hex(&self, hex_oids: &[&str]) -> Vec<Option<OidHit>>
pub fn lookup_batch_hex(&self, hex_oids: &[&str]) -> Vec<Option<OidHit>>
Hex convenience over lookup_batch.