Class DfsPackCompactor
The compactor combines several pack files together by including all objects contained in each pack file into the same output pack. If an object appears multiple times, it is only included once in the result. Because the new pack is constructed by enumerating the indexes of the source packs, it is quicker than doing a full repack of the repository, however the result is not nearly as space efficient as new delta compression is disabled.
This method is suitable for quickly combining several packs together after receiving a number of small fetch or push operations into a repository, allowing the system to maintain reasonable read performance without expending a lot of time repacking the entire repository.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate RevFlag
private int
private final List
<ObjectIdSet> private RevFlag
private PackStatistics
private DfsPackDescription
private ReftableConfig
private final DfsRepository
private RevWalk
private final List
<DfsPackFile> private final List
<DfsReftable> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(DfsPackFile pack) Add a pack to be compacted.add
(DfsReftable table) Add a reftable to be compacted.private void
addObjectsToPack
(PackWriter pw, DfsReader ctx, ProgressMonitor pm) autoAdd()
Automatically select pack and reftables to be included, and add them.void
Compact the pack files together.private void
compactPacks
(DfsReader ctx, ProgressMonitor pm) private void
(package private) static ReftableConfig
configureReftable
(ReftableConfig cfg, DfsOutputStream out) private long
exclude
(DfsPackFile pack) Exclude objects from the compacted pack.exclude
(ObjectIdSet set) Exclude objects from the compacted pack.Get new packs created by this compaction.Get statistics corresponding to thegetNewPacks()
.Get all of the source packs that fed into this compaction.private void
initOutDesc
(DfsObjDatabase objdb) Set configuration to write a reftable.private List
<DfsPackCompactor.ObjectIdWithOffset> toInclude
(DfsPackFile src, DfsReader ctx) private Collection
<DfsPackDescription> toPrune()
private static void
writeIndex
(DfsObjDatabase objdb, DfsPackDescription pack, PackWriter pw) private static void
writePack
(DfsObjDatabase objdb, DfsPackDescription pack, PackWriter pw, ProgressMonitor pm)
-
Field Details
-
repo
-
srcPacks
-
srcReftables
-
exclude
-
newStats
-
outDesc
-
autoAddSize
private int autoAddSize -
reftableConfig
-
rw
-
added
-
isBase
-
-
Constructor Details
-
DfsPackCompactor
Initialize a pack compactor.- Parameters:
repository
- repository objects to be packed will be read from.
-
-
Method Details
-
setReftableConfig
Set configuration to write a reftable.- Parameters:
cfg
- configuration to write a reftable. Reftable compacting is disabled (default) whencfg
isnull
.- Returns:
this
-
add
Add a pack to be compacted.All of the objects in this pack will be copied into the resulting pack. The resulting pack will order objects according to the source pack's own description ordering (which is based on creation date), and then by the order the objects appear in the source pack.
- Parameters:
pack
- a pack to combine into the resulting pack.- Returns:
this
-
add
Add a reftable to be compacted.- Parameters:
table
- a reftable to combine.- Returns:
this
-
autoAdd
Automatically select pack and reftables to be included, and add them.Packs are selected based on size, smaller packs get included while bigger ones are omitted.
- Returns:
this
- Throws:
IOException
- existing packs cannot be read.
-
exclude
Exclude objects from the compacted pack.- Parameters:
set
- objects to not include.- Returns:
this
.
-
exclude
Exclude objects from the compacted pack.- Parameters:
pack
- objects to not include.- Returns:
this
.- Throws:
IOException
- pack index cannot be loaded.
-
compact
Compact the pack files together.- Parameters:
pm
- progress monitor to receive updates on as packing may take a while, depending on the size of the repository.- Throws:
IOException
- the packs cannot be compacted.
-
compactPacks
private void compactPacks(DfsReader ctx, ProgressMonitor pm) throws IOException, IncorrectObjectTypeException -
estimatePackSize
private long estimatePackSize() -
compactReftables
- Throws:
IOException
-
initOutDesc
- Throws:
IOException
-
getSourcePacks
Get all of the source packs that fed into this compaction.- Returns:
- all of the source packs that fed into this compaction.
-
getNewPacks
Get new packs created by this compaction.- Returns:
- new packs created by this compaction.
-
getNewPackStatistics
Get statistics corresponding to thegetNewPacks()
. May be null if statistics are not available.- Returns:
- statistics corresponding to the
getNewPacks()
.
-
toPrune
-
addObjectsToPack
private void addObjectsToPack(PackWriter pw, DfsReader ctx, ProgressMonitor pm) throws IOException, IncorrectObjectTypeException -
toInclude
private List<DfsPackCompactor.ObjectIdWithOffset> toInclude(DfsPackFile src, DfsReader ctx) throws IOException - Throws:
IOException
-
writePack
private static void writePack(DfsObjDatabase objdb, DfsPackDescription pack, PackWriter pw, ProgressMonitor pm) throws IOException - Throws:
IOException
-
writeIndex
private static void writeIndex(DfsObjDatabase objdb, DfsPackDescription pack, PackWriter pw) throws IOException - Throws:
IOException
-
configureReftable
-