public static class Parameters.Builder
extends java.lang.Object
Parameters
instances.Modifier and Type | Field and Description |
---|---|
private java.lang.Boolean |
lazyMatches |
private java.lang.Integer |
lazyThreshold |
private int |
maxBackReferenceLength |
private java.lang.Integer |
maxCandidates |
private int |
maxLiteralLength |
private int |
maxOffset |
private int |
minBackReferenceLength |
private java.lang.Integer |
niceBackReferenceLength |
private int |
windowSize |
Modifier | Constructor and Description |
---|---|
private |
Builder(int windowSize) |
Modifier and Type | Method and Description |
---|---|
Parameters |
build()
Creates the
Parameters 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 mininal length of a back-reference.
|
Parameters.Builder |
withNiceBackReferenceLength(int niceLen)
Sets the "nice length" of a back-reference.
|
private final int windowSize
private int minBackReferenceLength
private int maxBackReferenceLength
private int maxOffset
private int maxLiteralLength
private java.lang.Integer niceBackReferenceLength
private java.lang.Integer maxCandidates
private java.lang.Integer lazyThreshold
private java.lang.Boolean lazyMatches
public Parameters.Builder withMinBackReferenceLength(int minBackReferenceLength)
Ensures maxBackReferenceLength
is not
smaller than minBackReferenceLength
.
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)
.
minBackReferenceLength
- the minimal length of a back-reference found. A
true minimum of 3 is hard-coded inside of this implemention
but bigger lengths can be configured.java.lang.IllegalArgumentException
- if windowSize
is smaller than minBackReferenceLength
.public Parameters.Builder withMaxBackReferenceLength(int maxBackReferenceLength)
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)
.
maxBackReferenceLength
- maximal length of a
back-reference found. A value smaller than
minBackReferenceLength
is interpreted as
minBackReferenceLength
. maxBackReferenceLength
is capped at windowSize - 1
.public Parameters.Builder withMaxOffset(int maxOffset)
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)
.
maxOffset
- maximal offset of a back-reference. A
non-positive value as well as values bigger than
windowSize - 1
are interpreted as windowSize
- 1
.public Parameters.Builder withMaxLiteralLength(int maxLiteralLength)
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)
.
maxLiteralLength
- maximal length of a literal
block. Negative numbers and 0 as well as values bigger than
windowSize
are interpreted as
windowSize
.public Parameters.Builder withNiceBackReferenceLength(int niceLen)
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.
niceLen
- the "nice length" of a back-referencepublic Parameters.Builder withMaxNumberOfCandidates(int maxCandidates)
This settings can be used to tune the tradeoff between compression speed and compression ratio.
maxCandidates
- maximum number of back-reference candidatespublic Parameters.Builder withLazyMatching(boolean lazy)
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.
lazy
- whether lazy matching should be performedpublic Parameters.Builder withLazyThreshold(int threshold)
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.
threshold
- the threshold for lazy matchingpublic Parameters.Builder tunedForSpeed()
Use this method after configuring "maximum back-reference length".
public Parameters.Builder tunedForCompressionRatio()
Use this method after configuring "maximum back-reference length".
public Parameters build()
Parameters
instance.Parameters
instance.