Class LzmaCompressionSettings


  • public class LzmaCompressionSettings
    extends CompressionSettings

    Settings for LZMA compression method.

    The Lempel–Ziv–Markov chain algorithm (LZMA) is an algorithm used to perform lossless data compression. This algorithm uses a dictionary compression scheme somewhat similar to the LZ77 algorithm and features a high compression ratio and a variable compression-dictionary size.

    See more: Lempel–Ziv–Markov chain algorithm

    • Constructor Detail

      • LzmaCompressionSettings

        public LzmaCompressionSettings()

        Initializes a new instance of the LzmaCompressionSettings class with default parameters.

        
             try (Archive archive = new Archive(new ArchiveEntrySettings(new LzmaCompressionSettings()))) {
                 archive.createEntry("data.bin", "data.bin");
                 archive.save(zipFile);
             }
         
      • LzmaCompressionSettings

        public LzmaCompressionSettings​(int dictionarySize,
                                       int numberOfFastBytes,
                                       int literalContextBits)

        Initializes a new instance of the LzmaCompressionSettings class with specified dictionary size, number of fast bytes and number of literal context bits.

        Parameters:
        dictionarySize - Dictionary (history buffer) size in bytes. Must be between 4096 and 1073741824.
        numberOfFastBytes - The number of bytes used for fast match searching in the LZMA algorithm. Can be in the range from 5 to 273.
        literalContextBits - Sets the number of literal context bits (high bits of previous literal). It can be in range from 0 to 8.
      • LzmaCompressionSettings

        public LzmaCompressionSettings​(int dictionarySize)

        Initializes a new instance of the LzmaCompressionSettings class with specified dictionary size, default number of fast bytes equal to 32 and number of literal context bits equal to 3.

        Parameters:
        dictionarySize - Dictionary (history buffer) size in bytes. Must be between 4096 and 1073741824.
    • Method Detail

      • getDictionarySize

        public final int getDictionarySize()

        Dictionary (history buffer) size indicates how many bytes of the recently processed uncompressed data are kept in memory.

        The bigger the dictionary, usually the better the compression ratio is - but dictionaries larger than the uncompressed data are a waste of RAM.

        Returns:
        how many bytes of the recently processed uncompressed data are kept in memory.
      • getNumberOfFastBytes

        public final int getNumberOfFastBytes()

        Gets the number of bytes used for fast match searching in the LZMA algorithm.

        A higher value allows the compressor to search longer matches, which can improve the compression ratio slightly but slows down compression.

        Returns:
        the number of bytes used for fast match searching in the LZMA algorithm.
      • getLiteralContextBits

        public final int getLiteralContextBits()

        Gets the number of literal context bits.

        Literal Context Bits define how many of the most significant bits of the previous uncompressed byte are used to predict the bits of the next literal byte. Must be from 0 to 8.

        Returns:
        the number of literal context bits.