Skip to main content

ObjectIndex

Trait ObjectIndex 

Source
pub trait ObjectIndex: Send + Sync {
    // Required methods
    fn build(entries: &[IndexEntry]) -> Result<Self>
       where Self: Sized;
    fn lookup(&self, oid: &[u8]) -> Option<IndexRow>;
    fn lookup_batch(&self, oids: &[&[u8]]) -> Vec<Option<IndexRow>>;
    fn ordinals_batch(&self, oids: &[&[u8]]) -> Vec<Option<u32>>;
    fn extents_batch(&self, oids: &[&[u8]]) -> Vec<Option<(u64, u64)>>;
    fn sum_uncompressed(&self) -> u64;
    fn count_type(&self, t: ObjType) -> usize;
    fn name(&self) -> &'static str;
    fn len(&self) -> usize;
    fn ipc_bytes(&self) -> usize;
    fn resident_bytes(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A git object index over Apache Arrow IPC.

build is where Self: Sized, so it stays out of the vtable and Box<dyn ObjectIndex> still works — which is how the bench drives both arms through one loop.

Required Methods§

Source

fn build(entries: &[IndexEntry]) -> Result<Self>
where Self: Sized,

Source

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

Resolve one oid. None for an absent oid and for an oid of the wrong width.

Source

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

The batch path, and the one that matters: have negotiation sends up to 1000 oids at a time, the push connectivity check sends thousands. Positional — out[i] answers oids[i].

This is the full-row access pattern: all five facts of each object.

Source

fn ordinals_batch(&self, oids: &[&[u8]]) -> Vec<Option<u32>>

oid → ordinal and stop. No payload column is touched at all.

Identical in every implementation, because every implementation shares the same stree. It is here as the floor: whatever this costs is what no payload layout can remove, and lookup_batch minus this is the only part any of these layouts can change. Without it a three-way tie is unreadable — it could mean the layouts are equivalent, or it could mean the harness never read a payload byte.

Source

fn extents_batch(&self, oids: &[&[u8]]) -> Vec<Option<(u64, u64)>>

The partial-row access pattern: byte extent only, two of the five facts. This is extents(&[oid]), what the wire path actually asks for when it is about to copy bytes out of a pack.

Source

fn sum_uncompressed(&self) -> u64

Full column scan: total uncompressed bytes over every object. The quota gate. Reads one 8-byte fact per row and nothing else.

Source

fn count_type(&self, t: ObjType) -> usize

Full column scan with a predicate: how many objects of this type. Reads one byte per row and nothing else — the most column-shaped query there is, and the one a row-packed layout should lose worst.

Source

fn name(&self) -> &'static str

Source

fn len(&self) -> usize

Source

fn ipc_bytes(&self) -> usize

Total bytes of Arrow IPC this index holds resident. Four sections or one, this counts the same payload, so it is comparable across arms.

Source

fn resident_bytes(&self) -> usize

IPC bytes plus the stree oid section — everything the index keeps alive, excluding the handful of Arc’d schema/metadata allocations.

Provided Methods§

Source

fn is_empty(&self) -> bool

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§