Class DfsPackDescription
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.dfs.DfsPackDescription
-
- Direct Known Subclasses:
InMemoryRepository.MemPack
public class DfsPackDescription extends java.lang.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.
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
blockSizeMap
private long
deltaCount
private long
estimatedPackSize
private int
extensions
private int
indexVersion
private long
lastModified
private long
maxUpdateIndex
private long
minUpdateIndex
private long
objectCount
private java.lang.String
packName
private DfsObjDatabase.PackSource
packSource
private PackStatistics
packStats
private ReftableWriter.Stats
refStats
private DfsRepositoryDescription
repoDesc
private long[]
sizeMap
-
Constructor Summary
Constructors Constructor Description DfsPackDescription(DfsRepositoryDescription repoDesc, java.lang.String name, DfsObjDatabase.PackSource packSource)
Initialize a description by pack name and repository.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFileExt(PackExt ext)
Adds the pack file extension to the known list.DfsPackDescription
clearPackStats()
Discard the pack statistics, if it was populated.boolean
equals(java.lang.Object b)
int
getBlockSize(PackExt ext)
Get blockSize of the file, in bytes.long
getDeltaCount()
Get number of delta compressed objects in the pack.long
getEstimatedPackSize()
Get estimated size of the .pack file in bytes.java.lang.String
getFileName(PackExt ext)
Get file namelong
getFileSize(PackExt ext)
Get size of the file, in bytes.int
getIndexVersion()
Get the version of the index file written.long
getLastModified()
Get time the pack was created, in milliseconds.long
getMaxUpdateIndex()
Get maxUpdateIndex for the reftable, if present.long
getMinUpdateIndex()
Get minUpdateIndex for the reftable, if present.long
getObjectCount()
Get number of objects in the pack.DfsObjDatabase.PackSource
getPackSource()
Get the source of the pack.PackStatistics
getPackStats()
Get statistics from PackWriter, if the pack was built with it.ReftableWriter.Stats
getReftableStats()
Get stats from the sibling reftable, if created.DfsRepositoryDescription
getRepositoryDescription()
Get description of the repository.DfsStreamKey
getStreamKey(PackExt ext)
Get cache key for use by the block cache.boolean
hasFileExt(PackExt ext)
Whether the pack file extension is known to exist.int
hashCode()
(package private) static boolean
isGC(DfsObjDatabase.PackSource s)
static java.util.Comparator<DfsPackDescription>
objectLookupComparator()
Comparator for packs when looking up objects in indexes.static java.util.Comparator<DfsPackDescription>
objectLookupComparator(java.util.Comparator<DfsObjDatabase.PackSource> packSourceComparator)
Comparator for packs when looking up objects in indexes.(package private) static java.util.Comparator<DfsPackDescription>
reftableComparator()
(package private) static java.util.Comparator<DfsPackDescription>
reuseComparator()
DfsPackDescription
setBlockSize(PackExt ext, int blockSize)
Set blockSize of the file, in bytes.DfsPackDescription
setDeltaCount(long cnt)
Set number of delta compressed objects in the pack.DfsPackDescription
setEstimatedPackSize(long estimatedPackSize)
Set estimated size of the .pack file in bytes.DfsPackDescription
setFileSize(PackExt ext, long bytes)
Set size of the file in bytes.DfsPackDescription
setIndexVersion(int version)
Set the version of the index file written.DfsPackDescription
setLastModified(long timeMillis)
Set time the pack was created, in milliseconds.DfsPackDescription
setMaxUpdateIndex(long max)
Set maxUpdateIndex for the reftable.DfsPackDescription
setMinUpdateIndex(long min)
Set minUpdateIndex for the reftable.DfsPackDescription
setObjectCount(long cnt)
Set number of objects in the pack.DfsPackDescription
setPackSource(DfsObjDatabase.PackSource source)
Set the source of the pack.(package private) DfsPackDescription
setPackStats(PackStatistics stats)
(package private) void
setReftableStats(ReftableWriter.Stats stats)
java.lang.String
toString()
-
-
-
Field Detail
-
repoDesc
private final DfsRepositoryDescription repoDesc
-
packName
private final java.lang.String packName
-
packSource
private DfsObjDatabase.PackSource packSource
-
lastModified
private long lastModified
-
sizeMap
private long[] sizeMap
-
blockSizeMap
private int[] blockSizeMap
-
objectCount
private long objectCount
-
deltaCount
private long deltaCount
-
minUpdateIndex
private long minUpdateIndex
-
maxUpdateIndex
private long maxUpdateIndex
-
packStats
private PackStatistics packStats
-
refStats
private ReftableWriter.Stats refStats
-
extensions
private int extensions
-
indexVersion
private int indexVersion
-
estimatedPackSize
private long estimatedPackSize
-
-
Constructor Detail
-
DfsPackDescription
public DfsPackDescription(DfsRepositoryDescription repoDesc, java.lang.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 java.util.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 java.util.Comparator<DfsPackDescription> objectLookupComparator(java.util.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 theDfsObjDatabase.PackSource
, used as the first step in comparison.- Returns:
- comparator.
-
reftableComparator
static java.util.Comparator<DfsPackDescription> reftableComparator()
-
reuseComparator
static java.util.Comparator<DfsPackDescription> reuseComparator()
-
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 java.lang.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.
-
getPackSource
@NonNull public DfsObjDatabase.PackSource getPackSource()
Get the source of the pack.- Returns:
- the source of the pack.
-
setPackSource
public DfsPackDescription setPackSource(@NonNull DfsObjDatabase.PackSource source)
Set the source of the pack.- Parameters:
source
- the source of the pack.- Returns:
this
-
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.
-
setPackStats
DfsPackDescription setPackStats(PackStatistics stats)
-
getReftableStats
public ReftableWriter.Stats getReftableStats()
Get stats from the sibling reftable, if created.- Returns:
- stats from the sibling reftable, if created.
-
setReftableStats
void setReftableStats(ReftableWriter.Stats stats)
-
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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object b)
- Overrides:
equals
in classjava.lang.Object
-
isGC
static boolean isGC(DfsObjDatabase.PackSource s)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-