pub struct PackIndex {
pub idx_path: PathBuf,
pub pack_path: PathBuf,
pub fanout: [u32; 256],
pub is_promisor: bool,
pub is_cruft: bool,
/* private fields */
}Expand description
Parsed pack index with fanout-accelerated OID lookup and in-place table reads.
Fields§
§idx_path: PathBufAbsolute path to the .idx file.
pack_path: PathBufAbsolute path to the .pack file.
fanout: [u32; 256]256-entry fanout: cumulative count of objects with first OID byte <= b.
is_promisor: boolSibling pack-*.promisor marker was present when this index was prepared.
is_cruft: boolSibling pack-*.mtimes marker was present when this index was prepared (cruft pack).
Implementations§
Source§impl PackIndex
impl PackIndex
Sourcepub fn hash_bytes(&self) -> usize
pub fn hash_bytes(&self) -> usize
OID width in bytes (20 for SHA-1, 32 for SHA-256).
Sourcepub fn offset_at(&self, i: usize) -> Result<u64>
pub fn offset_at(&self, i: usize) -> Result<u64>
Pack byte offset at sorted position i.
§Errors
Returns Error::CorruptObject when offset tables are malformed (including lazy-open
indexes that skipped full verification).
Sourcepub fn crc32_at(&self, i: usize) -> Option<u32>
pub fn crc32_at(&self, i: usize) -> Option<u32>
CRC32 at sorted position i (None for version-1 indexes).
Sourcepub fn find_position(&self, oid: &ObjectId) -> Option<usize>
pub fn find_position(&self, oid: &ObjectId) -> Option<usize>
Sorted-table position for oid, or None when absent or hash width mismatches.
Sourcepub fn find_offset(&self, oid: &ObjectId) -> Result<Option<u64>>
pub fn find_offset(&self, oid: &ObjectId) -> Result<Option<u64>>
Pack byte offset for oid, if present.
§Errors
Returns Error::CorruptObject when the matching row encodes an invalid offset.
Sourcepub fn find_offset_monotonic(
&self,
oid: &ObjectId,
cursor: &mut usize,
) -> Result<Option<u64>>
pub fn find_offset_monotonic( &self, oid: &ObjectId, cursor: &mut usize, ) -> Result<Option<u64>>
Like Self::find_offset but optimized for monotonically non-decreasing oid probes.
Updates cursor to the matching row on success. When the probe regresses (out-of-order
input), falls back to fanout + binary search and resets cursor.
Sourcepub fn contains(&self, oid: &ObjectId) -> Result<bool>
pub fn contains(&self, oid: &ObjectId) -> Result<bool>
Whether this pack index contains the given OID.
Sourcepub fn next_pack_offset_after(
&self,
entry_offset: u64,
pack_end: u64,
) -> Result<u64>
pub fn next_pack_offset_after( &self, entry_offset: u64, pack_end: u64, ) -> Result<u64>
Smallest pack offset strictly greater than entry_offset, capped at pack_end.
Uses the cached offset-sorted table, so repeated calls cost a binary search each.
§Errors
Returns an error when the index has a malformed large-offset entry.
Sourcepub fn crc32_for_pack_offset(&self, entry_offset: u64) -> Result<Option<u32>>
pub fn crc32_for_pack_offset(&self, entry_offset: u64) -> Result<Option<u32>>
CRC32 for the index row at entry_offset, if any.
Sourcepub fn find_position_by_offset_sorted(
&self,
offset: u64,
) -> Result<Option<usize>>
pub fn find_position_by_offset_sorted( &self, offset: u64, ) -> Result<Option<usize>>
Index row position of the object stored at pack byte offset.
Uses an offset-sorted table that is built once per index (from the .rev
sidecar when present) and shared by clones, so each lookup is a binary search.
Returns Ok(None) when no object starts at offset.
§Errors
Returns Error::CorruptObject when the index has a malformed large-offset entry.