Top Description Inners Fields Constructors Methods
org.apache.commons.compress.compressors.lz77support

public final Class Parameters

extends Object
Class Inheritance

Parameters of the compressor.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Parameters.Builder

Builder for Parameters instances.

Field Summary

Modifier and TypeField and Description
private final boolean
private final int
private final int
private final int
private final int
private final int
private final int
private final int
public static final int
TRUE_MIN_BACK_REFERENCE_LENGTH

The hard-coded absolute minimal length of a back-reference.

private final int

Constructor Summary

AccessConstructor and Description
private
Parameters(final int windowSize, final int minBackReferenceLength, final int maxBackReferenceLength, final int maxOffset, final int maxLiteralLength, final int niceBackReferenceLength, final int maxCandidates, final boolean lazyMatching, final int lazyThreshold)

Method Summary

Modifier and TypeMethod and Description
public static Parameters.Builder

Returns:

a builder configured for the given window size
builder
(final int
the size of the sliding window - this determines the maximum offset a back-reference can take. Must be a power of two.
windowSize
)

Initializes the builder for the compressor's parameters with a minBackReferenceLength of 3 and max*Length equal to windowSize - 1.

public boolean

Returns:

whether to perform lazy matching
getLazyMatching
()

Gets whether to perform lazy matching.

public int

Returns:

the threshold for lazy matching
getLazyMatchingThreshold
()

Gets the threshold for lazy matching.

public int

Returns:

the maximal length of a back-reference found
getMaxBackReferenceLength
()

Gets the maximal length of a back-reference found.

public int

Returns:

the maximum number of back-reference candidates to consider
getMaxCandidates
()

Gets the maximum number of back-reference candidates to consider.

public int

Returns:

the maximal length of a literal block
getMaxLiteralLength
()

Gets the maximal length of a literal block.

public int

Returns:

the maximal offset of a back-reference found
getMaxOffset
()

Gets the maximal offset of a back-reference found.

public int

Returns:

the minimal length of a back-reference found
getMinBackReferenceLength
()

Gets the minimal length of a back-reference found.

public int

Returns:

the length of a back-reference that is considered nice enough to stop searching
getNiceBackReferenceLength
()

Gets the length of a back-reference that is considered nice enough to stop searching for longer ones.

public int

Returns:

the size of the sliding window
getWindowSize
()

Gets the size of the sliding window - this determines the maximum offset a back-reference can take.

private static boolean
isPowerOfTwo(final int x)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lazyMatchingback to summary
private final boolean lazyMatching
lazyThresholdback to summary
private final int lazyThreshold
maxBackReferenceLengthback to summary
private final int maxBackReferenceLength
maxCandidatesback to summary
private final int maxCandidates
maxLiteralLengthback to summary
private final int maxLiteralLength
maxOffsetback to summary
private final int maxOffset
minBackReferenceLengthback to summary
private final int minBackReferenceLength
niceBackReferenceLengthback to summary
private final int niceBackReferenceLength
TRUE_MIN_BACK_REFERENCE_LENGTHback to summary
public static final int TRUE_MIN_BACK_REFERENCE_LENGTH

The hard-coded absolute minimal length of a back-reference.

windowSizeback to summary
private final int windowSize

Constructor Detail

Parametersback to summary
private Parameters(final int windowSize, final int minBackReferenceLength, final int maxBackReferenceLength, final int maxOffset, final int maxLiteralLength, final int niceBackReferenceLength, final int maxCandidates, final boolean lazyMatching, final int lazyThreshold)

Method Detail

builderback to summary
public static Parameters.Builder builder(final int windowSize)

Initializes the builder for the compressor's parameters with a minBackReferenceLength of 3 and max*Length equal to windowSize - 1.

It is recommended to not use this method directly but rather tune a pre-configured builder created by a format specific factory like org.apache.commons.compress.compressors.snappy.SnappyCompressorOutputStream#createParameterBuilder.

Parameters
windowSize:int

the size of the sliding window - this determines the maximum offset a back-reference can take. Must be a power of two.

Returns:Parameters.Builder

a builder configured for the given window size

Exceptions
IllegalArgumentException:
if windowSize is not a power of two.
getLazyMatchingback to summary
public boolean getLazyMatching()

Gets whether to perform lazy matching.

Returns:boolean

whether to perform lazy matching

getLazyMatchingThresholdback to summary
public int getLazyMatchingThreshold()

Gets the threshold for lazy matching.

Returns:int

the threshold for lazy matching

getMaxBackReferenceLengthback to summary
public int getMaxBackReferenceLength()

Gets the maximal length of a back-reference found.

Returns:int

the maximal length of a back-reference found

getMaxCandidatesback to summary
public int getMaxCandidates()

Gets the maximum number of back-reference candidates to consider.

Returns:int

the maximum number of back-reference candidates to consider

getMaxLiteralLengthback to summary
public int getMaxLiteralLength()

Gets the maximal length of a literal block.

Returns:int

the maximal length of a literal block

getMaxOffsetback to summary
public int getMaxOffset()

Gets the maximal offset of a back-reference found.

Returns:int

the maximal offset of a back-reference found

getMinBackReferenceLengthback to summary
public int getMinBackReferenceLength()

Gets the minimal length of a back-reference found.

Returns:int

the minimal length of a back-reference found

getNiceBackReferenceLengthback to summary
public int getNiceBackReferenceLength()

Gets the length of a back-reference that is considered nice enough to stop searching for longer ones.

Returns:int

the length of a back-reference that is considered nice enough to stop searching

getWindowSizeback to summary
public int getWindowSize()

Gets the size of the sliding window - this determines the maximum offset a back-reference can take.

Returns:int

the size of the sliding window

isPowerOfTwoback to summary
private static boolean isPowerOfTwo(final int x)
org.apache.commons.compress.compressors.lz77support back to summary

public Class Parameters.Builder

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.compress.compressors.lz77support.Parameters.Builder

Builder for Parameters instances.

Field Summary

Modifier and TypeField and Description
private Boolean
private Integer
private int
private Integer
private int
private int
private int
private Integer
private final int

Constructor Summary

AccessConstructor and Description
private
Builder(final int windowSize)

Method Summary

Modifier and TypeMethod and Description
public Parameters

Returns:

the configured Parameters instance.
build
()

Creates the Parameters instance.

public Parameters.Builder

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.

public Parameters.Builder

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.

public Parameters.Builder

Returns:

the builder
withLazyMatching
(final boolean
whether lazy matching should be performed
lazy
)

Sets whether lazy matching should be performed.

public Parameters.Builder

Returns:

the builder
withLazyThreshold
(final int
the threshold for lazy matching
threshold
)

Sets the threshold for lazy matching.

public Parameters.Builder

Returns:

the builder
withMaxBackReferenceLength
(final int
maximal length of a back-reference found. A value smaller than minBackReferenceLength is interpreted as minBackReferenceLength. maxBackReferenceLength is capped at windowSize - 1.
maxBackReferenceLength
)

Sets the maximal length of a back-reference.

public Parameters.Builder

Returns:

the builder
withMaxLiteralLength
(final int
maximal length of a literal block. Negative numbers and 0 as well as values bigger than windowSize are interpreted as windowSize.
maxLiteralLength
)

Sets the maximal length of a literal block.

public Parameters.Builder

Returns:

the builder
withMaxNumberOfCandidates
(final int
maximum number of back-reference candidates
maxCandidates
)

Sets the maximum number of back-reference candidates that should be consulted.

public Parameters.Builder

Returns:

the builder
withMaxOffset
(final int
maximal offset of a back-reference. A non-positive value as well as values bigger than windowSize - 1 are interpreted as windowSize - 1 .
maxOffset
)

Sets the maximal offset of a back-reference.

public Parameters.Builder

Returns:

the builder
withMinBackReferenceLength
(final int
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.
minBackReferenceLength
)

Sets the minimal length of a back-reference.

public Parameters.Builder

Returns:

the builder
withNiceBackReferenceLength
(final int
the "nice length" of a back-reference
niceLen
)

Sets the "nice length" of a back-reference.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lazyMatchesback to summary
private Boolean lazyMatches
lazyThresholdback to summary
private Integer lazyThreshold
maxBackReferenceLengthback to summary
private int maxBackReferenceLength
maxCandidatesback to summary
private Integer maxCandidates
maxLiteralLengthback to summary
private int maxLiteralLength
maxOffsetback to summary
private int maxOffset
minBackReferenceLengthback to summary
private int minBackReferenceLength
niceBackReferenceLengthback to summary
private Integer niceBackReferenceLength
windowSizeback to summary
private final int windowSize

Constructor Detail

Builderback to summary
private Builder(final int windowSize)

Method Detail

buildback to summary
public Parameters build()

Creates the Parameters instance.

Returns:Parameters

the configured Parameters instance.

tunedForCompressionRatioback to summary
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:Parameters.Builder

the builder

tunedForSpeedback to summary
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:Parameters.Builder

the builder

withLazyMatchingback to summary
public Parameters.Builder withLazyMatching(final 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:boolean

whether lazy matching should be performed

Returns:Parameters.Builder

the builder

withLazyThresholdback to summary
public Parameters.Builder withLazyThreshold(final 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:int

the threshold for lazy matching

Returns:Parameters.Builder

the builder

withMaxBackReferenceLengthback to summary
public Parameters.Builder withMaxBackReferenceLength(final 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 org.apache.commons.compress.compressors.snappy.SnappyCompressorOutputStream#createParameterBuilder.

Parameters
maxBackReferenceLength:int

maximal length of a back-reference found. A value smaller than minBackReferenceLength is interpreted as minBackReferenceLength. maxBackReferenceLength is capped at windowSize - 1.

Returns:Parameters.Builder

the builder

withMaxLiteralLengthback to summary
public Parameters.Builder withMaxLiteralLength(final 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 org.apache.commons.compress.compressors.snappy.SnappyCompressorOutputStream#createParameterBuilder.

Parameters
maxLiteralLength:int

maximal length of a literal block. Negative numbers and 0 as well as values bigger than windowSize are interpreted as windowSize.

Returns:Parameters.Builder

the builder

withMaxNumberOfCandidatesback to summary
public Parameters.Builder withMaxNumberOfCandidates(final 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:int

maximum number of back-reference candidates

Returns:Parameters.Builder

the builder

withMaxOffsetback to summary
public Parameters.Builder withMaxOffset(final 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 org.apache.commons.compress.compressors.snappy.SnappyCompressorOutputStream#createParameterBuilder.

Parameters
maxOffset:int

maximal offset of a back-reference. A non-positive value as well as values bigger than windowSize - 1 are interpreted as windowSize - 1 .

Returns:Parameters.Builder

the builder

withMinBackReferenceLengthback to summary
public Parameters.Builder withMinBackReferenceLength(final int minBackReferenceLength)

Sets the minimal length of a back-reference.

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 org.apache.commons.compress.compressors.snappy.SnappyCompressorOutputStream#createParameterBuilder.

Parameters
minBackReferenceLength:int

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:Parameters.Builder

the builder

Exceptions
IllegalArgumentException:
if windowSize is smaller than minBackReferenceLength.
withNiceBackReferenceLengthback to summary
public Parameters.Builder withNiceBackReferenceLength(final 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:int

the "nice length" of a back-reference

Returns:Parameters.Builder

the builder