Class PackDirectory

java.lang.Object
org.eclipse.jgit.internal.storage.file.PackDirectory

class PackDirectory extends Object
Traditional file system packed objects directory handler.

This is the Packs object representation for a Git object database, where objects are stored in compressed containers known as Packs.

  • Field Details

  • Constructor Details

    • PackDirectory

      PackDirectory(Config config, File directory)
      Initialize a reference to an on-disk 'pack' directory.
      Parameters:
      config - configuration this directory consults for write settings.
      directory - the location of the pack directory.
  • Method Details

    • getDirectory

      File getDirectory()
      Getter for the field directory.
      Returns:
      the location of the pack directory.
    • create

      void create() throws IOException
      Throws:
      IOException
    • close

      void close()
    • getPacks

      Collection<Pack> getPacks()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • has

      boolean has(AnyObjectId objectId)
      Does the requested object exist in this PackDirectory?
      Parameters:
      objectId - identity of the object to test for existence of.
      Returns:
      true if the specified object is stored in this PackDirectory.
    • getPack

      @Nullable Pack getPack(AnyObjectId objectId)
      Get the Pack for the specified object if it is stored in this PackDirectory.
      Parameters:
      objectId - identity of the object to find the Pack for.
      Returns:
      Pack which contains the specified object or null if it is not stored in this PackDirectory.
    • resolve

      boolean resolve(Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit)
      Find objects matching the prefix abbreviation.
      Parameters:
      matches - set to add any located ObjectIds to. This is an output parameter.
      id - prefix to search for.
      matchLimit - maximum number of results to return. At most this many ObjectIds should be added to matches before returning.
      Returns:
      true if the matches were exhausted before reaching maxLimit.
    • open

      ObjectLoader open(WindowCursor curs, AnyObjectId objectId)
    • getSize

      long getSize(WindowCursor curs, AnyObjectId id)
    • selectRepresentation

      void selectRepresentation(PackWriter packer, ObjectToPack otp, WindowCursor curs)
    • handlePackError

      private void handlePackError(IOException e, Pack p)
    • doLogExponentialBackoff

      private boolean doLogExponentialBackoff(int n)
      Parameters:
      n - count of consecutive failures
      Returns:
    • searchPacksAgain

      boolean searchPacksAgain(PackDirectory.PackList old)
    • insert

      void insert(Pack pack)
    • remove

      private void remove(Pack deadPack)
    • indexOf

      private static int indexOf(Pack[] list, Pack pack)
    • scanPacks

      private PackDirectory.PackList scanPacks(PackDirectory.PackList original)
    • scanPacksImpl

      private PackDirectory.PackList scanPacksImpl(PackDirectory.PackList old)
    • reuseMap

      private static Map<String,Pack> reuseMap(PackDirectory.PackList old)
    • getPackFilesByExtById

      private Map<String,Map<PackExt,PackFile>> getPackFilesByExtById()
      Scans the pack directory for PackFiles and returns them organized by their extensions and their pack ids Skips files in the directory that we cannot create a PackFile for.
      Returns:
      a map of PackFiles and PackExts keyed by pack ids