Class Parameters.Builder
- java.lang.Object
-
- org.apache.commons.compress.compressors.lz77support.Parameters.Builder
-
- Enclosing class:
- Parameters
public static class Parameters.Builder extends Object
Builder forParameters
instances.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Parameters
build()
Creates theParameters
instance.Parameters.Builder
tunedForCompressionRatio()
Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression ratio at the cost of compression speed.Parameters.Builder
tunedForSpeed()
Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression speed at the cost of compression ratio.Parameters.Builder
withLazyMatching(boolean lazy)
Sets whether lazy matching should be performed.Parameters.Builder
withLazyThreshold(int threshold)
Sets the threshold for lazy matching.Parameters.Builder
withMaxBackReferenceLength(int maxBackReferenceLength)
Sets the maximal length of a back-reference.Parameters.Builder
withMaxLiteralLength(int maxLiteralLength)
Sets the maximal length of a literal block.Parameters.Builder
withMaxNumberOfCandidates(int maxCandidates)
Sets the maximum number of back-reference candidates that should be consulted.Parameters.Builder
withMaxOffset(int maxOffset)
Sets the maximal offset of a back-reference.Parameters.Builder
withMinBackReferenceLength(int minBackReferenceLength)
Sets the minimal length of a back-reference.Parameters.Builder
withNiceBackReferenceLength(int niceLen)
Sets the "nice length" of a back-reference.
-
-
-
Method Detail
-
withMinBackReferenceLength
public Parameters.Builder withMinBackReferenceLength(int minBackReferenceLength)
Sets the minimal length of a back-reference.Ensures
maxBackReferenceLength
is not smaller thanminBackReferenceLength
.It is recommended to not use this method directly but rather tune a pre-configured builder created by a format specific factory like
SnappyCompressorOutputStream.createParameterBuilder(int)
.- Parameters:
minBackReferenceLength
- the minimal length of a back-reference found. A true minimum of 3 is hard-coded inside of this implementation but bigger lengths can be configured.- Returns:
- the builder
- Throws:
IllegalArgumentException
- ifwindowSize
is smaller thanminBackReferenceLength
.
-
withMaxBackReferenceLength
public Parameters.Builder withMaxBackReferenceLength(int maxBackReferenceLength)
Sets the maximal length of a back-reference.It is recommended to not use this method directly but rather tune a pre-configured builder created by a format specific factory like
SnappyCompressorOutputStream.createParameterBuilder(int)
.- Parameters:
maxBackReferenceLength
- maximal length of a back-reference found. A value smaller thanminBackReferenceLength
is interpreted asminBackReferenceLength
.maxBackReferenceLength
is capped atwindowSize - 1
.- Returns:
- the builder
-
withMaxOffset
public Parameters.Builder withMaxOffset(int maxOffset)
Sets the maximal offset of a back-reference.It is recommended to not use this method directly but rather tune a pre-configured builder created by a format specific factory like
SnappyCompressorOutputStream.createParameterBuilder(int)
.- Parameters:
maxOffset
- maximal offset of a back-reference. A non-positive value as well as values bigger thanwindowSize - 1
are interpreted aswindowSize - 1
.- Returns:
- the builder
-
withMaxLiteralLength
public Parameters.Builder withMaxLiteralLength(int maxLiteralLength)
Sets the maximal length of a literal block.It is recommended to not use this method directly but rather tune a pre-configured builder created by a format specific factory like
SnappyCompressorOutputStream.createParameterBuilder(int)
.- Parameters:
maxLiteralLength
- maximal length of a literal block. Negative numbers and 0 as well as values bigger thanwindowSize
are interpreted aswindowSize
.- Returns:
- the builder
-
withNiceBackReferenceLength
public Parameters.Builder withNiceBackReferenceLength(int niceLen)
Sets the "nice length" of a back-reference.When a back-references if this size has been found, stop searching for longer back-references.
This settings can be used to tune the tradeoff between compression speed and compression ratio.
- Parameters:
niceLen
- the "nice length" of a back-reference- Returns:
- the builder
-
withMaxNumberOfCandidates
public Parameters.Builder withMaxNumberOfCandidates(int maxCandidates)
Sets the maximum number of back-reference candidates that should be consulted.This settings can be used to tune the tradeoff between compression speed and compression ratio.
- Parameters:
maxCandidates
- maximum number of back-reference candidates- Returns:
- the builder
-
withLazyMatching
public Parameters.Builder withLazyMatching(boolean lazy)
Sets whether lazy matching should be performed.Lazy matching means that after a back-reference for a certain position has been found the compressor will try to find a longer match for the next position.
Lazy matching is enabled by default and disabled when tuning for speed.
- Parameters:
lazy
- whether lazy matching should be performed- Returns:
- the builder
-
withLazyThreshold
public Parameters.Builder withLazyThreshold(int threshold)
Sets the threshold for lazy matching.Even if lazy matching is enabled it will not be performed if the length of the back-reference found for the current position is longer than this value.
- Parameters:
threshold
- the threshold for lazy matching- Returns:
- the builder
-
tunedForSpeed
public Parameters.Builder tunedForSpeed()
Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression speed at the cost of compression ratio.Use this method after configuring "maximum back-reference length".
- Returns:
- the builder
-
tunedForCompressionRatio
public Parameters.Builder tunedForCompressionRatio()
Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression ratio at the cost of compression speed.Use this method after configuring "maximum back-reference length".
- Returns:
- the builder
-
build
public Parameters build()
Creates theParameters
instance.- Returns:
- the configured
Parameters
instance.
-
-