Class FastLzCompressor

    • Method Detail

      • newFactory

        public static Supplier<FastLzCompressor> newFactory()
        Creates a FastLZ compressor factory without checksum calculator and with auto detection of compression level.
        Returns:
        the factory.
      • newFactory

        public static Supplier<FastLzCompressor> newFactory​(int level)
        Creates a FastLZ compressor factory with specified compression level and without checksum calculator.
        Parameters:
        level - supports only these values: 0 - Encoder will choose level automatically depending on the length of the input buffer. 1 - Level 1 is the fastest compression and generally useful for short data. 2 - Level 2 is slightly slower but it gives better compression ratio.
        Returns:
        the factory.
      • newFactory

        public static Supplier<FastLzCompressor> newFactory​(boolean validateChecksums)
        Creates a FastLZ compressor factory with auto detection of compression level and calculation of checksums as specified.
        Parameters:
        validateChecksums - If true, the checksum of each block will be calculated and this value will be added to the header of block. By default FastLzCompressor uses Adler32 for checksum calculation.
        Returns:
        the factory.
      • newFactory

        public static Supplier<FastLzCompressor> newFactory​(int level,
                                                            Checksum checksum)
        Creates a FastLZ compressor factory with specified compression level and checksum calculator.
        Parameters:
        level - supports only these values: 0 - Encoder will choose level automatically depending on the length of the input buffer. 1 - Level 1 is the fastest compression and generally useful for short data. 2 - Level 2 is slightly slower but it gives better compression ratio.
        checksum - the Checksum instance to use to check data for integrity. You may set null if you don't want to validate checksum of each block.
        Returns:
        the factory.
      • compress

        public Buffer compress​(Buffer in,
                               BufferAllocator allocator)
                        throws CompressionException
        Description copied from interface: Compressor
        This method will read from the input Buffer and compress into a new Buffer that will be allocated (if needed) from the BufferAllocator. This method is expected to consume all data from the input but not take ownership. The caller is responsible to release the input buffer after this method returns.
        Specified by:
        compress in interface Compressor
        Parameters:
        in - the Buffer that contains the data to be compressed.
        allocator - the BufferAllocator that is used to allocate a new buffer (if needed) to write the compressed bytes too.
        Returns:
        the Buffer that contains the compressed data. The caller of this method takes ownership of the buffer. The return value will never be null.
        Throws:
        CompressionException - thrown if an compression error was encountered or the compressor was closed already.
      • finish

        public Buffer finish​(BufferAllocator allocator)
        Description copied from interface: Compressor
        By calling this method we signal that the compression stream is marked as finish. The returned Buffer might contain a "trailer" which marks the end of the stream.
        Specified by:
        finish in interface Compressor
        Returns:
        the Buffer which represent the end of the compression stream, which might be empty if the compressor don't need a trailer to signal the end. The caller of this method takes ownership of the buffer. The return value will never be null.
      • isClosed

        public boolean isClosed()
        Description copied from interface: Compressor
        Return true if the decompressor was closed, false otherwise.
        Specified by:
        isClosed in interface Compressor
        Returns:
        true if the decompressor was closed, false otherwise.