Class DfsPackDescription
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.dfs.DfsPackDescription
-
- All Implemented Interfaces:
Comparable<DfsPackDescription>
public class DfsPackDescription extends Object implements 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 Summary
Constructors Constructor Description DfsPackDescription(DfsRepositoryDescription repoDesc, String name)
Initialize a description by pack name and repository.
-
Method Summary
-
-
-
Constructor Detail
-
DfsPackDescription
public DfsPackDescription(DfsRepositoryDescription repoDesc, 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 String getFileName(PackExt ext)
- Parameters:
ext
- the file extension- Returns:
- name of the file.
-
getPackSource
public DfsObjDatabase.PackSource getPackSource()
- Returns:
- the source of the pack.
-
setPackSource
public DfsPackDescription setPackSource(DfsObjDatabase.PackSource source)
- Parameters:
source
- the source of the pack.- Returns:
this
-
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
-
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 interfaceComparable<DfsPackDescription>
- Parameters:
b
- the other pack.
-
-