PackWriter class is responsible for generating pack files from specified set of objects from repository. This implementation produce pack files in format version 2.
Source of objects may be specified in two ways:
org.eclipse.jgit.revwalk.RevObject
specifying exact list and order of objects in pack
Typical usage consists of creating an instance, configuring options,
preparing the list of objects by calling preparePack(Iterator) or
preparePack(ProgressMonitor, Set, Set), and streaming with
writePack(ProgressMonitor, ProgressMonitor, OutputStream). If the
pack is being stored as a file the matching index can be written out after
writing the pack by writeIndex(PackIndexWriter). An optional bitmap
index can be made by calling prepareBitmapIndex(ProgressMonitor)
followed by writeBitmapIndex(PackBitmapIndexWriter).
Class provide set of configurable options and
org. support, as operations may take
a long time for big repositories. Deltas searching algorithm is NOT
IMPLEMENTED yet - this implementation relies only on deltas and objects
reuse.
This class is not thread safe. It is intended to be used in one thread as a single pass to produce one pack. Invoking methods multiple times or out of order is not supported as internal data structures are destroyed during certain phases to save memory when packing large repositories.
| Modifier and Type | Class and Description |
|---|---|
| private static class | PackWriter.
A visitation policy which uses the depth at which the object is seen to decide if re-traversal is necessary. |
| private class | |
| public static class | PackWriter.
Configuration related to the packfile URI feature. |
| public static enum | PackWriter.
Possible states that a PackWriter can be in. |
| public class | PackWriter.
Summary of the current state of a PackWriter. |
| Modifier and Type | Field and Description |
|---|---|
| private List | |
| private ObjectCountCallback | |
| private boolean | |
| private boolean | |
| pack-priv final PackConfig | |
| private CRC32 | |
| private boolean | |
| private boolean | |
| private int | |
| private List | |
| private Set | |
| private ObjectIdSet | |
| private ObjectIdSet[] | |
| private FilterSpec | |
| private BitmapIndex. | |
| private boolean | |
| private boolean | |
| private static final Map | |
| private Deflater | |
| public static final Set | NONE
Empty set of objects for |
| pack-priv BlockList | |
| private ObjectIdOwnerMap | |
| private static final int | |
| private byte[] | |
| private PackWriter. | |
| private boolean | |
| private final ObjectReader | |
| private boolean | |
| private boolean | |
| private final ObjectReuseAsIs | reuseSupport
|
| private boolean | |
| private long | |
| private final Duration | |
| private final WeakReference | |
| private boolean | |
| private List | |
| private final PackWriter. | |
| private final PackStatistics. | |
| private Set | |
| private boolean | |
| private PackStatistics. | |
| private Collection | |
| private boolean | |
| private boolean | |
| private PackBitmapIndexBuilder |
| Access | Constructor and Description |
|---|---|
| public | PackWriter(Repository
repository where objects are stored. repo)Create writer for specified repository. |
| public | PackWriter(Repository
repository where objects are stored. repo, ObjectReader reader to read from the repository with. reader)Create writer for specified repository. |
| public | PackWriter(PackConfig
configuration for the pack writer. config, ObjectReader reader to read from the repository with. reader)Create writer with a specified configuration. |
| public | PackWriter(PackConfig
configuration for the pack writer. config, final ObjectReader reader to read from the repository with. reader, PackStatistics.accumulator for statics statsAccumulatorCreate writer with a specified configuration. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| private void | |
| private void | |
| private void | |
| private byte[] | |
| pack-priv static byte[] | |
| public void | |
| public void | close()
Implements java. Closes this resource, relinquishing any underlying resources. |
| public ObjectId | Returns: ObjectId representing SHA-1 name of a pack that was created.Computes SHA-1 of lexicographically sorted objects ids written in this pack, as used to name a pack file in repository. |
| private void | |
| private Deflater | |
| private TemporaryBuffer. | |
| private boolean | Returns: whether the given object should be skipped.the object to check whether it should be omitted. obj, ObjectWalk the walker being used for traveresal. walker)Determines if the object should be omitted from the pack as a result of its depth (probably because of the tree:<depth> filter). |
| public void | enableSearchForReuseTimeout()
Set the writer to check for long search for reuse, exceeding the timeout. |
| private void | |
| private boolean | |
| public void | excludeObjects(ObjectIdSet
objects in this index will not be in the output pack. idx)Add a pack index whose contents should be excluded from the result. |
| private void | |
| private int | |
| private void | findObjectsToPack(ProgressMonitor countingMonitor, ObjectWalk walker, Set<? extends ObjectId> want, Set<? extends ObjectId> have, Set<? extends ObjectId> noBitmaps)
|
| private void | findObjectsToPackUsingBitmaps(BitmapWalker bitmapWalker, Set<? extends ObjectId> want, Set<? extends ObjectId> have)
|
| public ObjectToPack | Returns: the object we are packing, or null.the object to find in the pack. id)Lookup the ObjectToPack object for a given ObjectId. |
| public int | Returns: the index format version.Returns the index format version that will be written. |
| public static Iterable | Returns: all allocated, non-released PackWriters instances.Get all allocated, non-released PackWriters instances. |
| public long | Returns: number of objects in pack.Returns objects number in a pack file that was created by this writer. |
| public ObjectIdOwnerMap | Returns: set of objects in pack.Returns the object ids in the pack file that was created by this writer. |
| private ObjectWalk | |
| public PackWriter. | Returns: snapshot of the current state of this PackWriter.Get snapshot of the current state of this PackWriter. |
| public PackStatistics | Returns: description of what this PackWriter did in order to create the final pack stream. This should only be invoked after the calls to create the pack/index/bitmap have completed.Get statistics of what this PackWriter did in order to create the final pack stream. |
| private long | |
| private final boolean | |
| private static Iterator | |
| public boolean | Returns: true if the bitmap file is to be created by this
PackWriter.Whether the bitmap file is to be created by this PackWriter. |
| public boolean | Returns: true if delta base is stored as an offset; false if it is stored as an object id.Check whether writer can store delta base as an offset (new style reducing pack size) or should store it as an object id (legacy style, compatible with old readers). |
| public boolean | Returns: true to ignore objects that are uninteresting and also
not found on local disk; false to throw a
org. out of
preparePack(ProgressMonitor, Set, Set) if an
uninteresting object is not in the source repository. By default,
true, permitting gracefully ignoring of uninteresting objects.Whether to ignore missing uninteresting objects |
| public boolean | Returns: true if the index file cannot be created by this
PackWriter.Whether the index file cannot be created by this PackWriter. |
| public boolean | Returns: true if the writer would reuse commits stored as deltas, assuming delta reuse is already enabled.Check if the writer will reuse commits that are already stored as deltas. |
| public boolean | Returns: true if validation is enabled; false if the reader will handle object validation as a side-effect of it consuming the output.Check if the writer validates objects before copying them. |
| public boolean | Returns: whether the writer will write a reverse index fileWhether the writer will write a reverse index file. |
| public boolean | Returns: true if this writer is producing a thin pack.Whether this writer is producing a thin pack. |
| public boolean | |
| public boolean | Returns: true to reuse cached packs. If true index creation isn't
available.Whether to reuse cached packs. |
| private void | |
| public boolean | Returns: whether a bitmap index may be written.progress monitor to report bitmap building work. pm)Prepares the bitmaps to be written to the bitmap index file. |
| public void | preparePack(Iterator<RevObject>
iterator of object to store in a pack; order of objects within
each type is important, ordering by type is not needed;
allowed types for objects are
objectsSource)org.,
org.,
org. and
org.; objects
returned by iterator may be later reused by caller as object
id and type are internally copied in each iteration.Prepare the list of objects to be written to the pack stream. |
| public void | preparePack(Collection<? extends CachedPack>
cached packs to be written. c)Prepare the list of objects to be written to the pack stream. |
| public void | preparePack(ProgressMonitor
progress during object enumeration. countingMonitor, Set<? extends ObjectId> collection of objects to be marked as interesting (start
points of graph traversal). Must not be want, Set<? extends ObjectId> null.collection of objects to be marked as uninteresting (end
points of graph traversal). Pass have)NONE if all objects
reachable from want are desired, such as when serving
a clone.Prepare the list of objects to be written to the pack stream. |
| public void | preparePack(ProgressMonitor
progress during object enumeration. countingMonitor, Set<? extends ObjectId> objects of interest, ancestors of which will be included in
the pack. Must not be want, Set<? extends ObjectId> null.objects whose ancestors (up to and including have, Set<? extends ObjectId> shallow
commits) do not need to be included in the pack because they
are already available from elsewhere. Must not be
null.commits indicating the boundary of the history marked with
shallow)have. Shallow commits have parents but those parents
are considered not to be already available. Parents of
shallow commits and earlier generations will be
included in the pack if requested by want. Must not be
null.Prepare the list of objects to be written to the pack stream. |
| public void | preparePack(ProgressMonitor
progress during object enumeration. countingMonitor, Set<? extends ObjectId> objects of interest, ancestors of which will be included in
the pack. Must not be want, Set<? extends ObjectId> null.objects whose ancestors (up to and including have, Set<? extends ObjectId> shallow
commits) do not need to be included in the pack because they
are already available from elsewhere. Must not be
null.commits indicating the boundary of the history marked with
shallow, Set<? extends ObjectId> have. Shallow commits have parents but those parents
are considered not to be already available. Parents of
shallow commits and earlier generations will be
included in the pack if requested by want. Must not be
null.collection of objects to be excluded from bitmap commit
selection. noBitmaps)Prepare the list of objects to be written to the pack stream. |
| public void | preparePack(ProgressMonitor
progress during object enumeration. countingMonitor, ObjectWalk ObjectWalk to perform enumeration. walk, Set<? extends ObjectId> collection of objects to be marked as interesting (start
points of graph traversal). Must not be interestingObjects, Set<? extends ObjectId> null.collection of objects to be marked as uninteresting (end
points of graph traversal). Pass uninterestingObjects, Set<? extends ObjectId> NONE if all objects
reachable from want are desired, such as when serving
a clone.collection of objects to be excluded from bitmap commit
selection. noBitmaps)Prepare the list of objects to be written to the pack stream. |
| private static void | |
| private void | |
| private boolean | |
| private static void | runTasks(ExecutorService pool, ThreadSafeProgressMonitor pm, DeltaTask.
|
| private void | |
| private void | |
| private void | |
| private void | |
| public void | select(ObjectToPack
the object being packed. otp, StoredObjectRepresentation the next available representation from the repository. next)Select an object representation for this writer. |
| public void | setClientShallowCommits(Set<ObjectId>
the shallow commits in the client clientShallowCommits)Records the set of shallow commits in the client. |
| public void | setCreateBitmaps(boolean
if set to true, bitmaps will be generated when creating a pack. createBitmaps)Whether to generate bitmaps. |
| public void | setDeltaBaseAsOffset(boolean
boolean indicating whether delta base can be stored as an
offset. deltaBaseAsOffset)Set writer delta base format. |
| public void | setFilterSpec(FilterSpec
the filter which indicates what and what not this writer
should include filter)Set filter spec |
| public void | setIgnoreMissingUninteresting(boolean
true if writer should ignore non existing
uninteresting objects during construction set of objects to
pack; false otherwise - non existing uninteresting objects may
cause org.Whether writer should ignore non existing uninteresting objects |
| public void | setIndexDisabled(boolean
true to disable creation of the index file.Whether to disable creation of the index file. |
| public PackWriter | Returns: this object for chaining.the callback to set callback)Set the |
| public void | setPackfileUriConfig(PackWriter.
configuration related to packfile URIs configSet packfile URI config |
| public void | setReuseDeltaCommits(boolean
if true, the writer will reuse any commits stored as deltas.
By default the writer does not reuse delta commits. reuse)Set the writer to reuse existing delta versions of commits. |
| public void | setReuseValidatingObjects(boolean
if true the pack writer will validate an object before it is
put into the output. This additional validation work may be
necessary to avoid propagating corruption from one local pack
file to another local pack file. validate)Enable (or disable) object validation during packing. |
| public void | setShallowPack(int
maximum depth of history to return. 1 means return only the
"wants". depth, Collection<? extends ObjectId> objects which used to be shallow on the client, but are being
extended as part of this fetch unshallow)Configure this pack for a shallow clone. |
| public void | setTagTargets(Set<ObjectId>
objects that annotated tags point at. objects)Set the tag targets that should be hoisted earlier during packing. |
| public void | setThin(boolean
a boolean indicating whether writer may pack objects with
delta base object not within set of objects to pack, but
belonging to party repository (uninteresting/boundary) as
determined by set; this kind of pack is used only for
transport; true - to produce thin pack, false - otherwise. packthin)Whether writer may pack objects with delta base object not within set of objects to pack |
| public void | setUseBitmaps(boolean
if set to true, bitmaps will be used when preparing a pack. useBitmaps)Whether to use bitmaps |
| public void | setUseCachedPacks(boolean
if set to useCached)true and a cached pack is present, it will
be appended onto the end of a thin-pack, reducing the amount
of working set space and CPU used by PackWriter. Enabling this
feature prevents PackWriter from creating an index for the
newly created pack, so its only suitable for writing to a
network client, where the client will make the index.Whether to use cached packs |
| private void | |
| private List | |
| public boolean | Returns: true if the object will appear in the output pack file.the object to test the existence of. id)Determine if the pack file will contain the requested object. |
| private void | |
| public void | writeBitmapIndex(PackBitmapIndexWriter
a writer to store the bitmap index in this object database bitmapIndexWriter)Create a bitmap index file to match the pack file just written. |
| private void | |
| private void | |
| public void | writeIndex(OutputStream
output for the index data. Caller is responsible for closing
this stream. indexStream)Create an index file to match the pack file just written. |
| public void | writeIndex(PackIndexWriter
an iw)PackIndexWriter instance to write the indexCreate an index file to match the pack file just written. |
| pack-priv void | |
| private void | |
| private void | |
| private void | |
| public void | writeObjectSizeIndex(OutputStream
output for the object size index data. Caller is responsible
for closing this stream. objIdxStream)Create an object size index file for the contents of the pack file just written. |
| public void | writePack(ProgressMonitor
progress monitor to report object compression work. compressMonitor, ProgressMonitor progress monitor to report the number of objects written. writeMonitor, OutputStream output stream of pack data. The stream should be buffered by
the caller. The caller is responsible for closing the stream. packStream)Write the prepared pack to the supplied stream. |
| public void | writeReverseIndex(OutputStream
where to write the file contents to stream)Write the pack's reverse index file to the output stream. |
| private void |