Class DfsPackDescription

  • All Implemented Interfaces:
    java.lang.Comparable<DfsPackDescription>

    public class DfsPackDescription
    extends java.lang.Object
    implements java.lang.Comparable<DfsPackDescription>
    Description of a DFS stored pack/index file.

    Implementors may extend this class and add additional data members.

    Instances of this class are cached with the DfsPackFile, and should not be modified once initialized and presented to the JGit DFS library.

    • Constructor Detail

      • DfsPackDescription

        public DfsPackDescription​(DfsRepositoryDescription repoDesc,
                                  java.lang.String name)
        Initialize a description by pack name and repository.

        The corresponding index file is assumed to exist. If this is not true implementors must extend the class and override getFileName(PackExt).

        Callers should also try to fill in other fields if they are reasonably free to access at the time this instance is being initialized.

        Parameters:
        name - name of the pack file. Must end with ".pack".
        repoDesc - description of the repo containing the pack file.
    • Method Detail

      • getRepositoryDescription

        public DfsRepositoryDescription getRepositoryDescription()
        Returns:
        description of the repository.
      • addFileExt

        public void addFileExt​(PackExt ext)
        Adds the pack file extension to the known list.
        Parameters:
        ext - the file extension
      • hasFileExt

        public boolean hasFileExt​(PackExt ext)
        Parameters:
        ext - the file extension
        Returns:
        whether the pack file extensions is known to exist.
      • getFileName

        public java.lang.String getFileName​(PackExt ext)
        Parameters:
        ext - the file extension
        Returns:
        name of the file.
      • getLastModified

        public long getLastModified()
        Returns:
        time the pack was created, in milliseconds.
      • setLastModified

        public DfsPackDescription setLastModified​(long timeMillis)
        Parameters:
        timeMillis - time the pack was created, in milliseconds. 0 if not known.
        Returns:
        this
      • setFileSize

        public DfsPackDescription setFileSize​(PackExt ext,
                                              long bytes)
        Parameters:
        ext - the file extension.
        bytes - size of the file in bytes. If 0 the file is not known and will be determined on first read.
        Returns:
        this
      • getFileSize

        public long getFileSize​(PackExt ext)
        Parameters:
        ext - the file extension.
        Returns:
        size of the file, in bytes. If 0 the file size is not yet known.
      • getObjectCount

        public long getObjectCount()
        Returns:
        number of objects in the pack.
      • setObjectCount

        public DfsPackDescription setObjectCount​(long cnt)
        Parameters:
        cnt - number of objects in the pack.
        Returns:
        this
      • getDeltaCount

        public long getDeltaCount()
        Returns:
        number of delta compressed objects in the pack.
      • setDeltaCount

        public DfsPackDescription setDeltaCount​(long cnt)
        Parameters:
        cnt - number of delta compressed objects in the pack.
        Returns:
        this
      • getPackStats

        public PackWriter.Statistics getPackStats()
        Returns:
        statistics from PackWriter, if the pack was built with it. Generally this is only available for packs created by DfsGarbageCollector or DfsPackCompactor, and only when the pack is being committed to the repository.
      • clearPackStats

        public DfsPackDescription clearPackStats()
        Discard the pack statistics, if it was populated.
        Returns:
        this
      • getIndexVersion

        public int getIndexVersion()
        Returns:
        the version of the index file written.
      • setIndexVersion

        public DfsPackDescription setIndexVersion​(int version)
        Parameters:
        version - the version of the index file written.
        Returns:
        this
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object b)
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(DfsPackDescription b)
        Sort packs according to the optimal lookup ordering.

        This method tries to position packs in the order readers should examine them when looking for objects by SHA-1. The default tries to sort packs with more recent modification dates before older packs, and packs with fewer objects before packs with more objects.

        Specified by:
        compareTo in interface java.lang.Comparable<DfsPackDescription>
        Parameters:
        b - the other pack.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object