java.lang.Object
org.eclipse.jgit.internal.storage.file.Pack
org.eclipse.jgit.internal.storage.file.PackMidx
All Implemented Interfaces:
Iterable<PackIndex.MutableEntry>

public class PackMidx extends Pack
A pack that uses internally a midx

This pack answers what it can directly from the midx (e.g. hasObject) and sends to the right pack other calls (e.g. reading the actual object).

  • Constructor Details

    • PackMidx

      public PackMidx(Config cfg, File midxFile, List<Pack> knownPacks) throws IOException
      Construct a reader for existing, pre-indexed packfiles.
      Parameters:
      cfg - configuration this directory consults for write settings.
      midxFile - path of the .midx file holding the data.
      knownPacks - packs in the repo to find the packs covered by this midx
      Throws:
      IOException - an error reading any of the files involved
  • Method Details

    • getCoveredPacks

      public List<Pack> getCoveredPacks()
      Return the packs covered by this midx (in midx order)
      Overrides:
      getCoveredPacks in class Pack
      Returns:
      packs covered by this midx
    • fullyIncludedIn

      protected List<Pack> fullyIncludedIn(BitmapIndex.BitmapBuilder needBitmaps) throws IOException
      Description copied from class: Pack
      Return the pack if all its objects are included in the need bitmaps.
      Overrides:
      fullyIncludedIn in class Pack
      Parameters:
      needBitmaps - bitmap with needed objects. Modified in this method: If a pack is fully included in the bitmap, the pack objects are removed from the bitmap.
      Returns:
      list of packs fully included in the bitmap
      Throws:
      IOException - an error reading the bitmap index of this pack
    • getIndex

      public PackIndex getIndex()
      Description copied from class: Pack
      Get the index for this pack file.
      Overrides:
      getIndex in class Pack
      Returns:
      the index for this pack file.
    • getReverseIdx

      public PackReverseIndex getReverseIdx()
      Description copied from class: Pack
      Get the reverse index of this pack
      Overrides:
      getReverseIdx in class Pack
      Returns:
      a reverse index
    • hasObjectSizeIndex

      public boolean hasObjectSizeIndex() throws IOException
      Description copied from class: Pack
      Get the object size index for this pack file
      Overrides:
      hasObjectSizeIndex in class Pack
      Returns:
      the object size index for this pack file if it exists (null otherwise)
      Throws:
      IOException - problem reading the index
    • getObjectSizeIndexCount

      public long getObjectSizeIndexCount()
      Description copied from class: Pack
      Number of objects in the object-size index of this pack
      Overrides:
      getObjectSizeIndexCount in class Pack
      Returns:
      number of objects in the index (0 if either the index is empty or it doesn't exist)
    • getIndexedObjectSize

      public long getIndexedObjectSize(AnyObjectId id) throws IOException
      Description copied from class: Pack
      Return the size of the object from the object-size index. Caller MUST check that the pack has object-size index (Pack.hasObjectSizeIndex()) and that the pack contains the object.
      Overrides:
      getIndexedObjectSize in class Pack
      Parameters:
      id - object id of an object in the pack
      Returns:
      size of the object from the index. Negative if the object is not in the index.
      Throws:
      IOException - if an IO error occurred while reading the index
    • hasObject

      public boolean hasObject(AnyObjectId id) throws IOException
      Description copied from class: Pack
      Determine if an object is contained within the pack file.

      For performance reasons only the index file is searched; the main pack content is ignored entirely.

      Overrides:
      hasObject in class Pack
      Parameters:
      id - the object to look for. Must not be null.
      Returns:
      true if the object is in this pack; false otherwise.
      Throws:
      IOException - the index file cannot be loaded into memory.
    • shouldBeKept

      public boolean shouldBeKept()
      Description copied from class: Pack
      Determines whether a .keep file exists for this pack file.
      Overrides:
      shouldBeKept in class Pack
      Returns:
      true if a .keep file exist.
    • closeIndices

      protected void closeIndices()
      Description copied from class: Pack
      Clear the indexes referenced in this pack.

      Subclasses override this method to clear references to any index they add

      Overrides:
      closeIndices in class Pack
    • iterator

      public Iterator<PackIndex.MutableEntry> iterator()
      Description copied from class: Pack

      Provide iterator over entries in associated pack index, that should also exist in this pack file. Objects returned by such iterator are mutable during iteration.

      Iterator returns objects in SHA-1 lexicographical order.

      Specified by:
      iterator in interface Iterable<PackIndex.MutableEntry>
      Overrides:
      iterator in class Pack
      See Also: