Class Parameters.Builder
- Enclosing class:
- Parameters
Parameters
instances.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates theParameters
instance.Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression ratio at the cost of compression speed.Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression speed at the cost of compression ratio.withLazyMatching
(boolean lazy) Sets whether lazy matching should be performed.withLazyThreshold
(int threshold) Sets the threshold for lazy matching.withMaxBackReferenceLength
(int maxBackReferenceLength) Sets the maximal length of a back-reference.withMaxLiteralLength
(int maxLiteralLength) Sets the maximal length of a literal block.withMaxNumberOfCandidates
(int maxCandidates) Sets the maximum number of back-reference candidates that should be consulted.withMaxOffset
(int maxOffset) Sets the maximal offset of a back-reference.withMinBackReferenceLength
(int minBackReferenceLength) Sets the minimal length of a back-reference.withNiceBackReferenceLength
(int niceLen) Sets the "nice length" of a back-reference.
-
Field Details
-
windowSize
private final int windowSize -
minBackReferenceLength
private int minBackReferenceLength -
maxBackReferenceLength
private int maxBackReferenceLength -
maxOffset
private int maxOffset -
maxLiteralLength
private int maxLiteralLength -
niceBackReferenceLength
-
maxCandidates
-
lazyThreshold
-
lazyMatches
-
-
Constructor Details
-
Builder
private Builder(int windowSize)
-
-
Method Details
-
withMinBackReferenceLength
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
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
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
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
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
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
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
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
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
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
Creates theParameters
instance.- Returns:
- the configured
Parameters
instance.
-