org.eclipse.jgit.storage.pack

## Class PackConfig

- java.lang.Object
- - org.eclipse.jgit.storage.pack.PackConfig

    public class PackConfig
    extends Object

Configuration used by a pack writer when constructing the stream. A configuration may be modified once created, but should not be modified while it is being used by a PackWriter. If a configuration is not modified it is safe to share the same configuration instance between multiple concurrent threads executing different PackWriters.

### Field Summary

Fields
`static int` `DEFAULT_BIG_FILE_THRESHOLD` Default big file threshold: 52428800
`static boolean` `DEFAULT_BUILD_BITMAPS` Default value of the build bitmaps option: true
`static boolean` `DEFAULT_DELTA_BASE_AS_OFFSET` Default value of delta base as offset option: false
`static int` `DEFAULT_DELTA_CACHE_LIMIT` Default delta cache limit: 100
`static long` `DEFAULT_DELTA_CACHE_SIZE` Default delta cache size: 52428800L
`static boolean` `DEFAULT_DELTA_COMPRESS` Default value of delta compress option: true
`static int` `DEFAULT_DELTA_SEARCH_WINDOW_SIZE` Default window size during packing: 10
`static int` `DEFAULT_INDEX_VERSION` Default index version: 2
`static int` `DEFAULT_MAX_DELTA_DEPTH` Default value of maximum delta chain depth: 50
`static boolean` `DEFAULT_REUSE_DELTAS` Default value of deltas reuse option: true
`static boolean` `DEFAULT_REUSE_OBJECTS` Default value of objects reuse option: true

### Constructor Summary

Constructors
Constructor and Description
`PackConfig()` Create a default configuration.
`PackConfig(Config cfg)` Create a configuration honoring settings in a `Config`.
`PackConfig(PackConfig cfg)` Copy an existing configuration to a new instance.
`PackConfig(Repository db)` Create a configuration honoring the repository's settings.

### Method Summary

Methods
`void` `fromConfig(Config rc)` Update properties by setting fields from the configuration.
`int` `getBigFileThreshold()` Get the maximum file size that will be delta compressed.
`int` `getCompressionLevel()` Get the compression level applied to objects in the pack.
`boolean` `getCutDeltaChains()`
`int` `getDeltaCacheLimit()` Maximum size in bytes of a delta to cache.
`long` `getDeltaCacheSize()` Get the size of the in-memory delta cache.
`long` `getDeltaSearchMemoryLimit()` Get maximum number of bytes to put into the delta search window.
`int` `getDeltaSearchWindowSize()` Get the number of objects to try when looking for a delta base.
`Executor` `getExecutor()`
`int` `getIndexVersion()` Get the pack index file format version this instance creates.
`int` `getMaxDeltaDepth()` Get maximum depth of delta chain set up for the writer.
`int` `getThreads()` Get the number of threads used during delta compression.
`boolean` `isBuildBitmaps()` True if writer is allowed to build bitmaps for indexes.
`boolean` `isDeltaBaseAsOffset()` True if writer can use offsets to point to a delta base.
`boolean` `isDeltaCompress()` Check whether the writer will create new deltas on the fly.
`boolean` `isReuseDeltas()` Check whether to reuse deltas existing in repository.
`boolean` `isReuseObjects()` Checks whether to reuse existing objects representation in repository.
`void` `setBigFileThreshold(int bigFileThreshold)` Set the maximum file size that should be considered for deltas.
`void` `setBuildBitmaps(boolean buildBitmaps)` Set writer to allow building bitmaps for supported pack files.
`void` `setCompressionLevel(int level)` Set the compression level applied to objects in the pack.
`void` `setCutDeltaChains(boolean cut)` Enable cutting existing delta chains at `getMaxDeltaDepth()`.
`void` `setDeltaBaseAsOffset(boolean deltaBaseAsOffset)` Set writer delta base format.
`void` `setDeltaCacheLimit(int size)` Set the maximum size of a delta that should be cached.
`void` `setDeltaCacheSize(long size)` Set the maximum number of bytes of delta data to cache.
`void` `setDeltaCompress(boolean deltaCompress)` Set whether or not the writer will create new deltas on the fly.
`void` `setDeltaSearchMemoryLimit(long memoryLimit)` Set the maximum number of bytes to put into the delta search window.
`void` `setDeltaSearchWindowSize(int objectCount)` Set the number of objects considered when searching for a delta base.
`void` `setExecutor(Executor executor)` Set the executor to use when using threads.
`void` `setIndexVersion(int version)` Set the pack index file format version this instance will create.
`void` `setMaxDeltaDepth(int maxDeltaDepth)` Set up maximum depth of delta chain for the writer.
`void` `setReuseDeltas(boolean reuseDeltas)` Set reuse deltas configuration option for the writer.
`void` `setReuseObjects(boolean reuseObjects)` Set reuse objects configuration option for the writer.
`void` `setThreads(int threads)` Set the number of threads to use for delta compression.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### DEFAULT_REUSE_DELTAS

    public static final boolean DEFAULT_REUSE_DELTAS

Default value of deltas reuse option: true

See Also:
  `setReuseDeltas(boolean)`, Constant Field Values

#### DEFAULT_REUSE_OBJECTS

    public static final boolean DEFAULT_REUSE_OBJECTS

Default value of objects reuse option: true

See Also:
  `setReuseObjects(boolean)`, Constant Field Values

#### DEFAULT_DELTA_COMPRESS

    public static final boolean DEFAULT_DELTA_COMPRESS

Default value of delta compress option: true

See Also:
  `setDeltaCompress(boolean)`, Constant Field Values

#### DEFAULT_DELTA_BASE_AS_OFFSET

    public static final boolean DEFAULT_DELTA_BASE_AS_OFFSET

Default value of delta base as offset option: false

See Also:
  `setDeltaBaseAsOffset(boolean)`, Constant Field Values

#### DEFAULT_MAX_DELTA_DEPTH

    public static final int DEFAULT_MAX_DELTA_DEPTH

Default value of maximum delta chain depth: 50

See Also:
  `setMaxDeltaDepth(int)`, Constant Field Values

#### DEFAULT_DELTA_SEARCH_WINDOW_SIZE

    public static final int DEFAULT_DELTA_SEARCH_WINDOW_SIZE

Default window size during packing: 10

See Also:
  `setDeltaSearchWindowSize(int)`, Constant Field Values

#### DEFAULT_BIG_FILE_THRESHOLD

    public static final int DEFAULT_BIG_FILE_THRESHOLD

Default big file threshold: 52428800

See Also:
  `setBigFileThreshold(int)`, Constant Field Values

#### DEFAULT_DELTA_CACHE_SIZE

    public static final long DEFAULT_DELTA_CACHE_SIZE

Default delta cache size: 52428800L

See Also:
  `setDeltaCacheSize(long)`, Constant Field Values

#### DEFAULT_DELTA_CACHE_LIMIT

    public static final int DEFAULT_DELTA_CACHE_LIMIT

Default delta cache limit: 100

See Also:
  `setDeltaCacheLimit(int)`, Constant Field Values

#### DEFAULT_INDEX_VERSION

    public static final int DEFAULT_INDEX_VERSION

Default index version: 2

See Also:
  `setIndexVersion(int)`, Constant Field Values

#### DEFAULT_BUILD_BITMAPS

    public static final boolean DEFAULT_BUILD_BITMAPS

Default value of the build bitmaps option: true

Since:
  3.0
See Also:
  `setBuildBitmaps(boolean)`, Constant Field Values

### Constructor Detail

#### PackConfig

    public PackConfig()

Create a default configuration.

#### PackConfig

    public PackConfig(Repository db)

Create a configuration honoring the repository's settings.

Parameters:
  `db` - the repository to read settings from. The repository is not retained by the new configuration, instead its settings are copied during the constructor.

#### PackConfig

    public PackConfig(Config cfg)

Create a configuration honoring settings in a `Config`.

Parameters:
  `cfg` - the source to read settings from. The source is not retained by the new configuration, instead its settings are copied during the constructor.

#### PackConfig

    public PackConfig(PackConfig cfg)

Copy an existing configuration to a new instance.

Parameters:
  `cfg` - the source configuration to copy from.

### Method Detail

#### isReuseDeltas

    public boolean isReuseDeltas()

Check whether to reuse deltas existing in repository. Default setting: true

Returns:
  true if object is configured to reuse deltas; false otherwise.

#### setReuseDeltas

    public void setReuseDeltas(boolean reuseDeltas)

Set reuse deltas configuration option for the writer. When enabled, writer will search for delta representation of object in repository and use it if possible. Normally, only deltas with base to another object existing in set of objects to pack will be used. The exception however is thin-packs where the base object may exist on the other side. When raw delta data is directly copied from a pack file, its checksum is computed to verify the data is not corrupt. Default setting: true

Parameters:
  `reuseDeltas` - boolean indicating whether or not try to reuse deltas.

#### isReuseObjects

    public boolean isReuseObjects()

Checks whether to reuse existing objects representation in repository. Default setting: true

Returns:
  true if writer is configured to reuse objects representation from pack; false otherwise.

#### setReuseObjects

    public void setReuseObjects(boolean reuseObjects)

Set reuse objects configuration option for the writer. If enabled, writer searches for compressed representation in a pack file. If possible, compressed data is directly copied from such a pack file. Data checksum is verified. Default setting: true

Parameters:
  `reuseObjects` - boolean indicating whether or not writer should reuse existing objects representation.

#### isDeltaBaseAsOffset

    public boolean isDeltaBaseAsOffset()

True if writer can use offsets to point to a delta base. If true the writer may choose to use an offset to point to a delta base in the same pack, this is a newer style of reference that saves space. False if the writer has to use the older (and more compatible style) of storing the full ObjectId of the delta base. Default setting: false

Returns:
  true if delta base is stored as an offset; false if it is stored as an ObjectId.

#### setDeltaBaseAsOffset

    public void setDeltaBaseAsOffset(boolean deltaBaseAsOffset)

Set writer delta base format. Delta base can be written as an offset in a pack file (new approach reducing file size) or as an object id (legacy approach, compatible with old readers). Default setting: false

Parameters:
  `deltaBaseAsOffset` - boolean indicating whether delta base can be stored as an offset.

#### isDeltaCompress

    public boolean isDeltaCompress()

Check whether the writer will create new deltas on the fly. Default setting: true

Returns:
  true if the writer will create a new delta when either `isReuseDeltas()` is false, or no suitable delta is available for reuse.

#### setDeltaCompress

    public void setDeltaCompress(boolean deltaCompress)

Set whether or not the writer will create new deltas on the fly. Default setting: true

Parameters:
  `deltaCompress` - true to create deltas when `isReuseDeltas()` is false, or when a suitable delta isn't available for reuse. Set to false to write whole objects instead.

#### getMaxDeltaDepth

    public int getMaxDeltaDepth()

Get maximum depth of delta chain set up for the writer. Generated chains are not longer than this value. Default setting: 50

Returns:
  maximum delta chain depth.

#### setMaxDeltaDepth

    public void setMaxDeltaDepth(int maxDeltaDepth)

Set up maximum depth of delta chain for the writer. Generated chains are not longer than this value. Too low value causes low compression level, while too big makes unpacking (reading) longer. Default setting: 50

Parameters:
  `maxDeltaDepth` - maximum delta chain depth.

#### getCutDeltaChains

    public boolean getCutDeltaChains()

Returns:
  true if existing delta chains should be cut at `getMaxDeltaDepth()`. Default is false, allowing existing chains to be of any length.
Since:
  3.0

#### setCutDeltaChains

    public void setCutDeltaChains(boolean cut)

Enable cutting existing delta chains at `getMaxDeltaDepth()`. By default this is disabled and existing chains are kept at whatever length a prior packer was configured to create. This allows objects to be packed one with a large depth (for example 250), and later to quickly repack the repository with a shorter depth (such as 50), but reusing the complete delta chains created by the earlier 250 depth.

Parameters:
  `cut` - true to cut existing chains.
Since:
  3.0

#### getDeltaSearchWindowSize

    public int getDeltaSearchWindowSize()

Get the number of objects to try when looking for a delta base. This limit is per thread, if 4 threads are used the actual memory used will be 4 times this value. Default setting: 10

Returns:
  the object count to be searched.

#### setDeltaSearchWindowSize

    public void setDeltaSearchWindowSize(int objectCount)

Set the number of objects considered when searching for a delta base. Default setting: 10

Parameters:
  `objectCount` - number of objects to search at once. Must be at least 2.

#### getDeltaSearchMemoryLimit

    public long getDeltaSearchMemoryLimit()

Get maximum number of bytes to put into the delta search window. Default setting is 0, for an unlimited amount of memory usage. Actual memory used is the lower limit of either this setting, or the sum of space used by at most `getDeltaSearchWindowSize()` objects. This limit is per thread, if 4 threads are used the actual memory limit will be 4 times this value.

Returns:
  the memory limit.

#### setDeltaSearchMemoryLimit

    public void setDeltaSearchMemoryLimit(long memoryLimit)

Set the maximum number of bytes to put into the delta search window. Default setting is 0, for an unlimited amount of memory usage. If the memory limit is reached before `getDeltaSearchWindowSize()` the window size is temporarily lowered.

Parameters:
  `memoryLimit` - Maximum number of bytes to load at once, 0 for unlimited.

#### getDeltaCacheSize

    public long getDeltaCacheSize()

Get the size of the in-memory delta cache. This limit is for the entire writer, even if multiple threads are used. Default setting: 52428800L

Returns:
  maximum number of bytes worth of delta data to cache in memory. If 0 the cache is infinite in size (up to the JVM heap limit anyway). A very tiny size such as 1 indicates the cache is effectively disabled.

#### setDeltaCacheSize

    public void setDeltaCacheSize(long size)

Set the maximum number of bytes of delta data to cache. During delta search, up to this many bytes worth of small or hard to compute deltas will be stored in memory. This cache speeds up writing by allowing the cached entry to simply be dumped to the output stream. Default setting: 52428800L

Parameters:
  `size` - number of bytes to cache. Set to 0 to enable an infinite cache, set to 1 (an impossible size for any delta) to disable the cache.

#### getDeltaCacheLimit

    public int getDeltaCacheLimit()

Maximum size in bytes of a delta to cache. Default setting: 100

Returns:
  maximum size (in bytes) of a delta that should be cached.

#### setDeltaCacheLimit

    public void setDeltaCacheLimit(int size)

Set the maximum size of a delta that should be cached. During delta search, any delta smaller than this size will be cached, up to the `getDeltaCacheSize()` maximum limit. This speeds up writing by allowing these cached deltas to be output as-is. Default setting: 100

Parameters:
  `size` - maximum size (in bytes) of a delta to be cached.

#### getBigFileThreshold

    public int getBigFileThreshold()

Get the maximum file size that will be delta compressed. Files bigger than this setting will not be delta compressed, as they are more than likely already highly compressed binary data files that do not delta compress well, such as MPEG videos. Default setting: 52428800

Returns:
  the configured big file threshold.

#### setBigFileThreshold

    public void setBigFileThreshold(int bigFileThreshold)

Set the maximum file size that should be considered for deltas. Default setting: 52428800

Parameters:
  `bigFileThreshold` - the limit, in bytes.

#### getCompressionLevel

    public int getCompressionLevel()

Get the compression level applied to objects in the pack. Default setting: -1

Returns:
  current compression level, see `Deflater`.

#### setCompressionLevel

    public void setCompressionLevel(int level)

Set the compression level applied to objects in the pack. Default setting: -1

Parameters:
  `level` - compression level, must be a valid level recognized by the `Deflater` class.

#### getThreads

    public int getThreads()

Get the number of threads used during delta compression. Default setting: 0 (auto-detect processors)

Returns:
  number of threads used for delta compression. 0 will auto-detect the threads to the number of available processors.

#### setThreads

    public void setThreads(int threads)

Set the number of threads to use for delta compression. During delta compression, if there are enough objects to be considered the writer will start up concurrent threads and allow them to compress different sections of the repository concurrently. An application thread pool can be set by `setExecutor(Executor)`. If not set a temporary pool will be created by the writer, and torn down automatically when compression is over. Default setting: 0 (auto-detect processors)

Parameters:
  `threads` - number of threads to use. If <= 0 the number of available processors for this JVM is used.

#### getExecutor

    public Executor getExecutor()

Returns:
  the preferred thread pool to execute delta search on.

#### setExecutor

    public void setExecutor(Executor executor)

Set the executor to use when using threads. During delta compression if the executor is non-null jobs will be queued up on it to perform delta compression in parallel. Aside from setting the executor, the caller must set `setThreads(int)` to enable threaded delta search.

Parameters:
  `executor` - executor to use for threads. Set to null to create a temporary executor just for the writer.

#### getIndexVersion

    public int getIndexVersion()

Get the pack index file format version this instance creates. Default setting: 2

Returns:
  the index version, the special version 0 designates the oldest (most compatible) format available for the objects.
See Also:
  `PackIndexWriter`

#### setIndexVersion

    public void setIndexVersion(int version)

Set the pack index file format version this instance will create. Default setting: 2

Parameters:
  `version` - the version to write. The special version 0 designates the oldest (most compatible) format available for the objects.
See Also:
  `PackIndexWriter`

#### isBuildBitmaps

    public boolean isBuildBitmaps()

True if writer is allowed to build bitmaps for indexes. Default setting: true

Returns:
  true if delta base is the writer can choose to output an index with bitmaps.
Since:
  3.0

#### setBuildBitmaps

    public void setBuildBitmaps(boolean buildBitmaps)

Set writer to allow building bitmaps for supported pack files. Index files can include bitmaps to speed up future ObjectWalks. Default setting: true

Parameters:
  `buildBitmaps` - boolean indicating whether bitmaps may be included in the index.
Since:
  3.0

#### fromConfig

    public void fromConfig(Config rc)

Update properties by setting fields from the configuration. If a property's corresponding variable is not defined in the supplied configuration, then it is left unmodified.

Parameters:
  `rc` - configuration to read properties from.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`