Class DfsPackFileMidx

java.lang.Object
org.eclipse.jgit.internal.storage.dfs.DfsPackFile
org.eclipse.jgit.internal.storage.dfs.DfsPackFileMidx
Direct Known Subclasses:
DfsPackFileMidxNPacks, DfsPackFileMidxSingle

public abstract sealed class DfsPackFileMidx extends DfsPackFile permits DfsPackFileMidxNPacks, DfsPackFileMidxSingle
DfsPackFile with the extra methods to support midx.

This is an abstract class to keep the inheritance from DfsPackFile and allow a dummy implementation for single packs.

We implement at this level methods that just translate midx to pack offsets and forward to the pack.

  • Field Details

    • invalidatingCause

      protected volatile Exception invalidatingCause
      Exception that caused the packfile to be flagged as invalid
  • Constructor Details

    • DfsPackFileMidx

      protected DfsPackFileMidx(DfsBlockCache cache, DfsPackDescription desc)
      Default constructor
      Parameters:
      cache - dfs block cache
      desc - midx pack description
  • Method Details

    • create

      public static DfsPackFileMidx create(DfsBlockCache cache, DfsPackDescription desc, List<DfsPackFile> requiredPacks, @Nullable DfsPackFileMidx base)
      Create a midx pack
      Parameters:
      cache - dfs block cache
      desc - description of the pack, covering at least one other pack
      requiredPacks - DfsPackFile instances of the covered packs
      base - midx acting a base of this
      Returns:
      a midx pack
    • getMultipackIndexBase

      public abstract DfsPackFileMidx getMultipackIndexBase()
      Base of this multipack index

      If this midx is part of a chain, this is its parent

      Returns:
      the base of this multipack index
    • getCoveredPacks

      public abstract List<DfsPackFile> getCoveredPacks()
      Packs indexed by this multipack index (base NOT included) in midx order.
      Returns:
      packs indexed by this multipack index in the order used inside the midx.
    • getAllCoveredPacks

      public List<DfsPackFile> getAllCoveredPacks()
      All packs indexed by this multipack index and its chain

      This does not include the inner multipack indexes themselves, only their covered packs.

      Returns:
      packs indexed by this multipack index and its parents.
    • getObjectCount

      protected int getObjectCount(DfsReader ctx) throws IOException
      Count of objects in this pack (i.e. including, recursively, its base)
      Parameters:
      ctx - a reader
      Returns:
      count of objects in this pack, including its bases
      Throws:
      IOException - an error reading a midx in the chain
    • getChecksum

      protected abstract byte[] getChecksum(DfsReader ctx) throws IOException
      Return checksum of the midx
      Parameters:
      ctx - a reader
      Returns:
      checksum of the midx
      Throws:
      IOException - an error reading the file
    • localIterator

      protected abstract MultiPackIndex.MidxIterator localIterator(DfsReader ctx) throws IOException
      Get a midx iterator over the contents of *this* midx, without the base.
      Parameters:
      ctx - a ready
      Returns:
      an iterator over the objects in this midx in sha1 order
      Throws:
      IOException - an error loading the underlying data
    • getPackIndex

      public final PackIndex getPackIndex(DfsReader ctx)
      Description copied from class: DfsPackFile
      Get the PackIndex for this PackFile.
      Overrides:
      getPackIndex in class DfsPackFile
      Parameters:
      ctx - reader context to support reading from the backing store if the index is not already loaded in memory.
      Returns:
      the PackIndex.
    • getReverseIdx

      public abstract PackReverseIndex getReverseIdx(DfsReader ctx) throws IOException
      Description copied from class: DfsPackFile
      Get the PackReverseIndex for this PackFile.
      Overrides:
      getReverseIdx in class DfsPackFile
      Parameters:
      ctx - reader context to support reading from the backing store if the index is not already loaded in memory
      Returns:
      the PackReverseIndex
      Throws:
      IOException - the pack index is not available, or is corrupt
    • getOffsetCalculator

      protected abstract DfsPackFileMidx.VOffsetCalculator getOffsetCalculator()
      Get the object calculator of this midx
      Returns:
      an offset calculator for this midx (including its chain)