Support for Git packfile bitmaps.
Bitmaps store reachability information for packfiles, enabling faster object counting and enumeration operations without full graph traversal.
The bitmap format uses EWAH (Enhanced Word-Aligned Hybrid) compression for efficient storage and fast bitwise operations.
| Class | |
A single bitmap entry for a commit. |
| Class | |
EWAH (Enhanced Word-Aligned Hybrid) compressed bitmap. |
| Class | |
A pack bitmap index. |
| Function | apply |
Apply XOR compression to bitmaps. |
| Function | bitmap |
Convert a bitmap to a set of object SHAs. |
| Function | build |
Build name-hash cache for all objects in a pack. |
| Function | build |
Build a reachability bitmap for a commit. |
| Function | build |
Build type bitmaps for all objects in a pack. |
| Function | find |
Find which packs have bitmaps for the given commits. |
| Function | generate |
Generate a complete bitmap for a pack. |
| Function | read |
Read a bitmap index file. |
| Function | read |
Read bitmap data from a file object. |
| Function | select |
Select commits for bitmap generation. |
| Function | write |
Write a bitmap index file. |
| Function | write |
Write bitmap data to a file object. |
| Constant | BITMAP |
Undocumented |
| Constant | BITMAP |
Undocumented |
| Constant | BITMAP |
Undocumented |
| Constant | BITMAP |
Undocumented |
| Constant | BITMAP |
Undocumented |
| Constant | BITMAP |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | MAX |
Undocumented |
| Constant | MAX |
Undocumented |
| Function | _compute |
Compute the name hash for a tree entry. |
| Function | _encode |
Encode a list of 64-bit words using EWAH run-length compression. |
list[ tuple[ ObjectID, EWAHBitmap]], max_xor_offset: int = MAX_XOR_OFFSET) -> list[ tuple[ ObjectID, EWAHBitmap, int]]:
¶
Apply XOR compression to bitmaps.
XOR compression stores some bitmaps as XOR differences from previous bitmaps, reducing storage size when bitmaps are similar.
| Parameters | |
bitmaps:list[ | List of (commit_sha, bitmap) tuples |
maxint | Maximum offset to search for XOR base |
| Returns | |
list[ | List of (commit_sha, bitmap, xor_offset) tuples |
EWAHBitmap, pack_index: PackIndex, type_filter: EWAHBitmap | None = None) -> set[ ObjectID]:
¶
Convert a bitmap to a set of object SHAs.
| Parameters | |
bitmap:EWAHBitmap | The EWAH bitmap with set bits for objects |
packPackIndex | Pack index to map positions to SHAs |
typeEWAHBitmap | None | Optional type bitmap to filter results (e.g., commits only) |
| Returns | |
set[ | Set of object SHAs (hex format) |
dict[ RawObjectID, int], object_store: BaseObjectStore) -> list[ int]:
¶
Build name-hash cache for all objects in a pack.
The name-hash cache stores a hash of the name for each object, which can speed up path-based operations.
| Parameters | |
shadict[ | Pre-built mapping from SHA to position in pack |
objectBaseObjectStore | Object store to read objects |
| Returns | |
list[ | List of 32-bit hash values, one per object in the pack |
ObjectID, sha_to_pos: dict[ RawObjectID, int], object_store: BaseObjectStore) -> EWAHBitmap:
¶
Build a reachability bitmap for a commit.
The bitmap has a bit set for each object that is reachable from the commit. The bit position corresponds to the object's position in the pack index.
| Parameters | |
commitObjectID | The commit to build a bitmap for |
shadict[ | Pre-built mapping from SHA to position in pack |
objectBaseObjectStore | Object store to traverse objects |
| Returns | |
EWAHBitmap | EWAH bitmap with bits set for reachable objects |
dict[ RawObjectID, int], object_store: BaseObjectStore) -> tuple[ EWAHBitmap, EWAHBitmap, EWAHBitmap, EWAHBitmap]:
¶
Build type bitmaps for all objects in a pack.
Type bitmaps classify objects by type: commit, tree, blob, or tag.
| Parameters | |
shadict[ | Pre-built mapping from SHA to position in pack |
objectBaseObjectStore | Object store to read object types |
| Returns | |
tuple[ | Tuple of (commit_bitmap, tree_bitmap, blob_bitmap, tag_bitmap) |
set[ ObjectID], packs: Iterable[ Pack]) -> dict[ ObjectID, tuple[ Pack, PackBitmap, dict[ RawObjectID, int]]]:
¶
Find which packs have bitmaps for the given commits.
| Parameters | |
commitset[ | Set of commit SHAs to look for |
packs:Iterable[ | Iterable of Pack objects to search |
| Returns | |
dict[ | Dict mapping commit SHA to (pack, pack_bitmap, position) tuple |
PackIndex, object_store: BaseObjectStore, refs: dict[ Ref, ObjectID], pack_checksum: bytes, include_hash_cache: bool = True, include_lookup_table: bool = True, commit_interval: int | None = None, progress: Callable[ [ str], None] | None = None) -> PackBitmap:
¶
Generate a complete bitmap for a pack.
| Parameters | |
packPackIndex | Pack index for the pack |
objectBaseObjectStore | Object store to read objects from |
refs:dict[ | Dictionary of ref names to commit SHAs |
packbytes | SHA-1 checksum of the pack file |
includebool | Whether to include name-hash cache |
includebool | Whether to include lookup table |
commitint | None | Include every Nth commit in history (None for default) |
progress:Callable[ | Optional progress reporting callback |
| Returns | |
PackBitmap | Complete PackBitmap ready to write to disk |
str | os.PathLike[ str], pack_index: PackIndex | None = None) -> PackBitmap:
¶
Read a bitmap index file.
| Parameters | |
filename:str | os.PathLike[ | Path to the .bitmap file |
packPackIndex | None | Optional PackIndex to resolve object positions to SHAs |
| Returns | |
PackBitmap | Loaded PackBitmap |
| Raises | |
ValueError | If file format is invalid |
ChecksumMismatch | If checksum verification fails |
Read bitmap data from a file object.
| Parameters | |
f:IO[ | File object to read from |
packPackIndex | None | Optional PackIndex to resolve object positions to SHAs |
| Returns | |
PackBitmap | Loaded PackBitmap |
| Raises | |
ValueError | If file format is invalid |
dict[ Ref, ObjectID], object_store: BaseObjectStore, commit_interval: int = DEFAULT_COMMIT_INTERVAL) -> list[ ObjectID]:
¶
Select commits for bitmap generation.
Uses Git's strategy: - All branch and tag tips - Every Nth commit in history
| Parameters | |
refs:dict[ | Dictionary of ref names to commit SHAs |
objectBaseObjectStore | Object store to read commits from |
commitint | Include every Nth commit in history |
| Returns | |
list[ | List of commit SHAs to create bitmaps for |
Write a bitmap index file.
| Parameters | |
filename:str | os.PathLike[ | Path to write the .bitmap file |
bitmap:PackBitmap | PackBitmap to write |
Write bitmap data to a file object.
| Parameters | |
f:IO[ | File object to write to |
bitmap:PackBitmap | PackBitmap to write |