Class DfsPackDescription


  • public class DfsPackDescription
    extends Object
    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,
                                  String name,
                                  @NonNull
                                  DfsObjDatabase.PackSource packSource)
        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.
        packSource - the source of the pack.
    • Method Detail

      • objectLookupComparator

        public static Comparator<DfsPackDescription> objectLookupComparator()
        Comparator for packs when looking up objects in indexes.

        This comparator 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.

        Uses DfsObjDatabase.PackSource.DEFAULT_COMPARATOR for the portion of comparison where packs are sorted by source.

        Returns:
        comparator.
      • objectLookupComparator

        public static Comparator<DfsPackDescription> objectLookupComparator​(Comparator<DfsObjDatabase.PackSource> packSourceComparator)
        Comparator for packs when looking up objects in indexes.

        This comparator 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.

        Parameters:
        packSourceComparator - comparator for the DfsObjDatabase.PackSource, used as the first step in comparison.
        Returns:
        comparator.
      • getRepositoryDescription

        public DfsRepositoryDescription getRepositoryDescription()
        Get description of the repository.
        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)
        Whether the pack file extension is known to exist.
        Parameters:
        ext - the file extension
        Returns:
        whether the pack file extension is known to exist.
      • getFileName

        public String getFileName​(PackExt ext)
        Get file name
        Parameters:
        ext - the file extension
        Returns:
        name of the file.
      • getStreamKey

        public DfsStreamKey getStreamKey​(PackExt ext)
        Get cache key for use by the block cache.
        Parameters:
        ext - the file extension.
        Returns:
        cache key for use by the block cache.
      • getLastModified

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

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

        public long getMinUpdateIndex()
        Get minUpdateIndex for the reftable, if present.
        Returns:
        minUpdateIndex for the reftable, if present.
      • setMinUpdateIndex

        public DfsPackDescription setMinUpdateIndex​(long min)
        Set minUpdateIndex for the reftable.
        Parameters:
        min - minUpdateIndex for the reftable.
        Returns:
        this
      • getMaxUpdateIndex

        public long getMaxUpdateIndex()
        Get maxUpdateIndex for the reftable, if present.
        Returns:
        maxUpdateIndex for the reftable, if present.
      • setMaxUpdateIndex

        public DfsPackDescription setMaxUpdateIndex​(long max)
        Set maxUpdateIndex for the reftable.
        Parameters:
        max - maxUpdateIndex for the reftable.
        Returns:
        this
      • setFileSize

        public DfsPackDescription setFileSize​(PackExt ext,
                                              long bytes)
        Set size of the file in 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)
        Get size of the file, in bytes.
        Parameters:
        ext - the file extension.
        Returns:
        size of the file, in bytes. If 0 the file size is not yet known.
      • getBlockSize

        public int getBlockSize​(PackExt ext)
        Get blockSize of the file, in bytes.
        Parameters:
        ext - the file extension.
        Returns:
        blockSize of the file, in bytes. If 0 the blockSize size is not yet known and may be discovered when opening the file.
      • setBlockSize

        public DfsPackDescription setBlockSize​(PackExt ext,
                                               int blockSize)
        Set blockSize of the file, in bytes.
        Parameters:
        ext - the file extension.
        blockSize - blockSize of the file, in bytes. If 0 the blockSize is not known and will be determined on first read.
        Returns:
        this
      • setEstimatedPackSize

        public DfsPackDescription setEstimatedPackSize​(long estimatedPackSize)
        Set estimated size of the .pack file in bytes.
        Parameters:
        estimatedPackSize - estimated size of the .pack file in bytes. If 0 the pack file size is unknown.
        Returns:
        this
      • getEstimatedPackSize

        public long getEstimatedPackSize()
        Get estimated size of the .pack file in bytes.
        Returns:
        estimated size of the .pack file in bytes. If 0 the pack file size is unknown.
      • getObjectCount

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

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

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

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

        public PackStatistics getPackStats()
        Get statistics from PackWriter, if the pack was built with it.
        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.
      • getReftableStats

        public ReftableWriter.Stats getReftableStats()
        Get stats from the sibling reftable, if created.
        Returns:
        stats from the sibling reftable, if created.
      • clearPackStats

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

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

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

        public int hashCode()
        Overrides:
        hashCode in class Object