public interface PackReverseIndex
Reverse index for forward pack index. Provides operations based on offset instead of object id. Such offset-based reverse lookups are performed in O(log n) time.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionlong
findNextOffset
(long offset, long maxOffset) Search for the next offset to the specified offset in this pack (reverse) index.findObject
(long offset) Search for object id with the specified start offset in this pack (reverse) index.findObjectByPosition
(int nthPosition) Find the object that is in the given position in the primary index.int
findPosition
(long offset) Find the position in the primary index of the object at the given pack offset.void
verifyPackChecksum
(String packFilePath) Verify that the pack checksum found in the reverse index matches that from the pack file.
-
Field Details
-
MAGIC
static final byte[] MAGICMagic bytes that uniquely identify git reverse index files. -
VERSION_1
static final int VERSION_1The first reverse index file version.- See Also:
-
-
Method Details
-
verifyPackChecksum
Verify that the pack checksum found in the reverse index matches that from the pack file.- Parameters:
packFilePath
- the path to display in event of a mismatch- Throws:
PackMismatchException
- if the checksums do not match
-
findObject
Search for object id with the specified start offset in this pack (reverse) index.- Parameters:
offset
- start offset of object to find.- Returns:
- object id for this offset, or null if no object was found.
-
findNextOffset
Search for the next offset to the specified offset in this pack (reverse) index.- Parameters:
offset
- start offset of previous object (must be valid-existing offset).maxOffset
- maximum offset in a pack (returned when there is no next offset).- Returns:
- offset of the next object in a pack or maxOffset if provided offset was the last one.
- Throws:
CorruptObjectException
- when there is no object with the provided offset.
-
findPosition
int findPosition(long offset) Find the position in the primary index of the object at the given pack offset.- Parameters:
offset
- the pack offset of the object- Returns:
- the position in the primary index of the object
-
findObjectByPosition
Find the object that is in the given position in the primary index.- Parameters:
nthPosition
- the position of the object in the primary index- Returns:
- the object in that position
-