class documentation

Multi-pack-index for efficient object lookup across multiple pack files.

Method __contains__ Check if the given object SHA is in this MIDX.
Method __init__ Initialize a MultiPackIndex.
Method __len__ Return the number of objects in this MIDX.
Method close Close the MIDX file and release mmap resources.
Method iterentries Iterate over all entries in this MIDX.
Method object_offset Return the pack name and offset for the given object.
Instance Variable base_midx_files Undocumented
Instance Variable chunk_count Undocumented
Instance Variable hash_algorithm Undocumented
Instance Variable hash_size Undocumented
Instance Variable object_count Undocumented
Instance Variable pack_count Undocumented
Instance Variable pack_names Undocumented
Instance Variable version Undocumented
Method _get_oid Get the object ID at the given index.
Method _get_pack_info Get pack ID and offset for object at the given index.
Method _load_file_contents Load contents from a file, preferring mmap when possible.
Method _parse_chunk_table Parse the chunk lookup table.
Method _parse_header Parse the MIDX header.
Method _parse_loff_chunk Parse the Large Offsets (LOFF) chunk.
Method _parse_oidf_chunk Parse the OID Fanout (OIDF) chunk.
Method _parse_oidl_chunk Parse the OID Lookup (OIDL) chunk.
Method _parse_ooff_chunk Parse the Object Offsets (OOFF) chunk.
Method _parse_pnam_chunk Parse the Packfile Names (PNAM) chunk.
Instance Variable _chunks Undocumented
Instance Variable _contents Undocumented
Instance Variable _fanout_table Undocumented
Instance Variable _file Undocumented
Instance Variable _filename Undocumented
Instance Variable _loff_offset Undocumented
Instance Variable _oidl_offset Undocumented
Instance Variable _ooff_offset Undocumented
Instance Variable _size Undocumented
def __contains__(self, sha: ObjectID | RawObjectID) -> bool:

Check if the given object SHA is in this MIDX.

Parameters
sha:ObjectID | RawObjectIDBinary SHA hash
Returns
boolTrue if the object is in this MIDX
def __init__(self, filename: str | os.PathLike[str], file: IO[bytes] | _GitFile | None = None, contents: bytes | None = None, size: int | None = None):

Initialize a MultiPackIndex.

Parameters
filename:str | os.PathLike[str]Path to the MIDX file
file:IO[bytes] | _GitFile | NoneOptional file object
contents:bytes | NoneOptional mmap'd contents
size:int | NoneOptional size of the MIDX file
def __len__(self) -> int:

Return the number of objects in this MIDX.

def close(self):

Close the MIDX file and release mmap resources.

def iterentries(self) -> Iterator[tuple[RawObjectID, str, int]]:

Iterate over all entries in this MIDX.

Yields
Tuples of (sha, pack_name, offset)
def object_offset(self, sha: ObjectID | RawObjectID) -> tuple[str, int] | None:

Return the pack name and offset for the given object.

Parameters
sha:ObjectID | RawObjectIDBinary SHA-1 or SHA-256 hash
Returns
tuple[str, int] | NoneTuple of (pack_name, offset) or None if not found
base_midx_files: int =

Undocumented

chunk_count: int =

Undocumented

hash_algorithm: int =

Undocumented

hash_size: int =

Undocumented

object_count: int =

Undocumented

pack_count: int =

Undocumented

pack_names: list[str] =

Undocumented

version: int =

Undocumented

def _get_oid(self, index: int) -> RawObjectID:

Get the object ID at the given index.

Parameters
index:intIndex of the object
Returns
RawObjectIDBinary object ID
def _get_pack_info(self, index: int) -> tuple[int, int]:

Get pack ID and offset for object at the given index.

Parameters
index:intIndex of the object
Returns
tuple[int, int]Tuple of (pack_id, offset)
def _load_file_contents(self, f: IO[bytes] | _GitFile, size: int | None = None) -> tuple[bytes | Any, int]:

Load contents from a file, preferring mmap when possible.

Parameters
f:IO[bytes] | _GitFileFile-like object to load
size:int | NoneExpected size, or None to determine from file
Returns
tuple[bytes | Any, int]Tuple of (contents, size)
def _parse_chunk_table(self):

Parse the chunk lookup table.

def _parse_header(self):

Parse the MIDX header.

def _parse_loff_chunk(self):

Parse the Large Offsets (LOFF) chunk.

def _parse_oidf_chunk(self):

Parse the OID Fanout (OIDF) chunk.

def _parse_oidl_chunk(self):

Parse the OID Lookup (OIDL) chunk.

def _parse_ooff_chunk(self):

Parse the Object Offsets (OOFF) chunk.

def _parse_pnam_chunk(self):

Parse the Packfile Names (PNAM) chunk.

_chunks: dict[bytes, int] =

Undocumented

_contents =

Undocumented

_fanout_table: list[int] =

Undocumented

_file =

Undocumented

_filename =

Undocumented

_loff_offset: int =

Undocumented

_oidl_offset: int =

Undocumented

_ooff_offset: int =

Undocumented

_size =

Undocumented