Interface PackReverseIndex


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.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte[]
    Magic bytes that uniquely identify git reverse index files.
    static final int
    The first reverse index file version.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    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[] MAGIC
      Magic bytes that uniquely identify git reverse index files.
    • VERSION_1

      static final int VERSION_1
      The first reverse index file version.
      See Also:
  • Method Details

    • verifyPackChecksum

      void verifyPackChecksum(String packFilePath) throws PackMismatchException
      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

      ObjectId findObject(long offset)
      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

      long findNextOffset(long offset, long maxOffset) throws CorruptObjectException
      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

      ObjectId findObjectByPosition(int nthPosition)
      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