Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.storage.dfs

public Class DfsPackCompactor

extends Object
Class Inheritance
Static Imports
org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.COMPACT, .DfsObjDatabase.PackSource.GC, org.eclipse.jgit.internal.storage.pack.PackExt.OBJECT_SIZE_INDEX, .PackExt.PACK, .PackExt.REFTABLE, .StoredObjectRepresentation.PACK_DELTA

Combine several pack files into one pack.

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 and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private 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

AccessConstructor and Description
public
DfsPackCompactor(DfsRepository
repository objects to be packed will be read from.
repository
)

Initialize a pack compactor.

Method Summary

Modifier and TypeMethod and Description
public DfsPackCompactor

Returns:

this
add
(DfsPackFile
a pack to combine into the resulting pack.
pack
)

Add a pack to be compacted.

public DfsPackCompactor

Returns:

this
add
(DfsReftable
a reftable to combine.
table
)

Add a reftable to be compacted.

private void
public DfsPackCompactor

Returns:

this
autoAdd
()

Automatically select pack and reftables to be included, and add them.

public void
compact(ProgressMonitor
progress monitor to receive updates on as packing may take a while, depending on the size of the repository.
pm
)

Compact the pack files together.

private void
private void
pack-priv static ReftableConfig
private long
public DfsPackCompactor

Returns:

this.
exclude
(ObjectIdSet
objects to not include.
set
)

Exclude objects from the compacted pack.

public DfsPackCompactor

Returns:

this.
exclude
(DfsPackFile
objects to not include.
pack
)

Exclude objects from the compacted pack.

public List<DfsPackDescription>

Returns:

new packs created by this compaction.
getNewPacks
()

Get new packs created by this compaction.

public List<PackStatistics>

Returns:

statistics corresponding to the getNewPacks().
getNewPackStatistics
()

Get statistics corresponding to the getNewPacks().

public Collection<DfsPackDescription>

Returns:

all of the source packs that fed into this compaction.
getSourcePacks
()

Get all of the source packs that fed into this compaction.

private void
public DfsPackCompactor

Returns:

this
setReftableConfig
(ReftableConfig
configuration to write a reftable. Reftable compacting is disabled (default) when cfg is null.
cfg
)

Set configuration to write a reftable.

private List<DfsPackCompactor.ObjectIdWithOffset>
private Collection<DfsPackDescription>
private static void
private static void
private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addedback to summary
private RevFlag added
autoAddSizeback to summary
private int autoAddSize
excludeback to summary
private final List<ObjectIdSet> exclude
isBaseback to summary
private RevFlag isBase
newStatsback to summary
private PackStatistics newStats
outDescback to summary
private DfsPackDescription outDesc
reftableConfigback to summary
private ReftableConfig reftableConfig
repoback to summary
private final DfsRepository repo
rwback to summary
private RevWalk rw
srcPacksback to summary
private final List<DfsPackFile> srcPacks
srcReftablesback to summary
private final List<DfsReftable> srcReftables

Constructor Detail

DfsPackCompactorback to summary
public DfsPackCompactor(DfsRepository repository)

Initialize a pack compactor.

Parameters
repository:DfsRepository

repository objects to be packed will be read from.

Method Detail

addback to summary
public DfsPackCompactor add(DfsPackFile pack)

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:DfsPackFile

a pack to combine into the resulting pack.

Returns:DfsPackCompactor

this

addback to summary
public DfsPackCompactor add(DfsReftable table)

Add a reftable to be compacted.

Parameters
table:DfsReftable

a reftable to combine.

Returns:DfsPackCompactor

this

addObjectsToPackback to summary
private void addObjectsToPack(PackWriter pw, DfsReader ctx, ProgressMonitor pm) throws IOException, IncorrectObjectTypeException
autoAddback to summary
public DfsPackCompactor autoAdd() throws IOException

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:DfsPackCompactor

this

Exceptions
IOException:
existing packs cannot be read.
compactback to summary
public void compact(ProgressMonitor pm) throws IOException

Compact the pack files together.

Parameters
pm:ProgressMonitor

progress monitor to receive updates on as packing may take a while, depending on the size of the repository.

Exceptions
IOException:
the packs cannot be compacted.
compactPacksback to summary
private void compactPacks(DfsReader ctx, ProgressMonitor pm) throws IOException, IncorrectObjectTypeException
compactReftablesback to summary
private void compactReftables(DfsReader ctx) throws IOException
configureReftableback to summary
pack-priv static ReftableConfig configureReftable(ReftableConfig cfg, DfsOutputStream out)
estimatePackSizeback to summary
private long estimatePackSize()
excludeback to summary
public DfsPackCompactor exclude(ObjectIdSet set)

Exclude objects from the compacted pack.

Parameters
set:ObjectIdSet

objects to not include.

Returns:DfsPackCompactor

this.

excludeback to summary
public DfsPackCompactor exclude(DfsPackFile pack) throws IOException

Exclude objects from the compacted pack.

Parameters
pack:DfsPackFile

objects to not include.

Returns:DfsPackCompactor

this.

Exceptions
IOException:
pack index cannot be loaded.
getNewPacksback to summary
public List<DfsPackDescription> getNewPacks()

Get new packs created by this compaction.

Returns:List<DfsPackDescription>

new packs created by this compaction.

getNewPackStatisticsback to summary
public List<PackStatistics> getNewPackStatistics()

Get statistics corresponding to the getNewPacks(). May be null if statistics are not available.

Returns:List<PackStatistics>

statistics corresponding to the getNewPacks().

getSourcePacksback to summary
public Collection<DfsPackDescription> getSourcePacks()

Get all of the source packs that fed into this compaction.

Returns:Collection<DfsPackDescription>

all of the source packs that fed into this compaction.

initOutDescback to summary
private void initOutDesc(DfsObjDatabase objdb) throws IOException
setReftableConfigback to summary
public DfsPackCompactor setReftableConfig(ReftableConfig cfg)

Set configuration to write a reftable.

Parameters
cfg:ReftableConfig

configuration to write a reftable. Reftable compacting is disabled (default) when cfg is null.

Returns:DfsPackCompactor

this

toIncludeback to summary
private List<DfsPackCompactor.ObjectIdWithOffset> toInclude(DfsPackFile src, DfsReader ctx) throws IOException
toPruneback to summary
private Collection<DfsPackDescription> toPrune()
writeIndexback to summary
private static void writeIndex(DfsObjDatabase objdb, DfsPackDescription pack, PackWriter pw) throws IOException
writeObjectSizeIndexback to summary
private static void writeObjectSizeIndex(DfsObjDatabase objdb, DfsPackDescription pack, PackWriter pw) throws IOException
writePackback to summary
private static void writePack(DfsObjDatabase objdb, DfsPackDescription pack, PackWriter pw, ProgressMonitor pm) throws IOException
org.eclipse.jgit.internal.storage.dfs back to summary

private Class DfsPackCompactor.ObjectIdWithOffset

extends ObjectId
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from org.eclipse.jgit.lib.ObjectId:
equalsfromRawfromRawfromRawfromRawfromRawfromStringfromStringisIdtoObjectIdtoStringzeroId

Field Detail

offsetback to summary
pack-priv final long offset

Constructor Detail

ObjectIdWithOffsetback to summary
pack-priv ObjectIdWithOffset(AnyObjectId id, long ofs)