Top Description Inners Fields Constructors Methods
io.netty5.handler.codec.compression

public final Class FastLzCompressor

extends Object
implements Compressor
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.compression.Compressor, java.lang.AutoCloseable
Imports
io.netty5.buffer.Buffer, .BufferAllocator, java.util.function.Supplier, java.util.zip.Adler32, .Checksum

Compresses a Buffer using the FastLZ algorithm. See FastLZ format.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private final BufferChecksum
checksum

Underlying checksum calculator in use.

private final int
level

Compression level.

private FastLzCompressor.State

Constructor Summary

AccessConstructor and Description
private
FastLzCompressor(int
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.
level
,
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.
checksum
)

Creates a FastLZ encoder with specified compression level and checksum calculator.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements io.netty5.handler.codec.compression.Compressor.close.

# Close the compressor.
public Buffer
compress(Buffer
the Buffer that contains the data to be compressed.
in
,
BufferAllocator
the BufferAllocator that is used to allocate a new buffer (if needed) to write the compressed bytes too.
allocator
)

Implements io.netty5.handler.codec.compression.Compressor.compress.

This method will read from the input Buffer and compress into a new Buffer that will be allocated (if needed) from the BufferAllocator.
private Buffer
public Buffer
finish(BufferAllocator allocator)

Implements io.netty5.handler.codec.compression.Compressor.finish.

By calling this method we signal that the compression stream is marked as finish.
public boolean
isClosed()

Implements io.netty5.handler.codec.compression.Compressor.isClosed.

Return true if the decompressor was closed, false otherwise.
public boolean
isFinished()

Implements io.netty5.handler.codec.compression.Compressor.isFinished.

Returns true if the compressor was finished or closed.
public static Supplier<FastLzCompressor>

Returns:

the factory.
newFactory
()

Creates a FastLZ compressor factory without checksum calculator and with auto detection of compression level.

public static Supplier<FastLzCompressor>

Returns:

the factory.
newFactory
(int
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.
level
)

Creates a FastLZ compressor factory with specified compression level and without checksum calculator.

public static Supplier<FastLzCompressor>

Returns:

the factory.
newFactory
(boolean
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 java.util.zip.Adler32 for checksum calculation.
validateChecksums
)

Creates a FastLZ compressor factory with auto detection of compression level and calculation of checksums as specified.

public static Supplier<FastLzCompressor>

Returns:

the factory.
newFactory
(int
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.
level
,
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.
checksum
)

Creates a FastLZ compressor factory with specified compression level and checksum calculator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checksumback to summary
private final BufferChecksum checksum

Underlying checksum calculator in use.

levelback to summary
private final int level

Compression level.

stateback to summary
private FastLzCompressor.State state

Constructor Detail

FastLzCompressorback to summary
private FastLzCompressor(int level, Checksum checksum)

Creates a FastLZ encoder with specified compression level and checksum calculator.

Parameters
level:int

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

Method Detail

closeback to summary
public void close()

Implements io.netty5.handler.codec.compression.Compressor.close.

Doc from io.netty5.handler.codec.compression.Compressor.close.

# Close the compressor. After this method was called isFinished() will return true as well and it is not allowed to call compress(Buffer, BufferAllocator) or finish(BufferAllocator) anymore -

Annotations
@Override
compressback to summary
public Buffer compress(Buffer in, BufferAllocator allocator) throws CompressionException

Implements io.netty5.handler.codec.compression.Compressor.compress.

Doc from io.netty5.handler.codec.compression.Compressor.compress.

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.

Parameters
in:Buffer

the Buffer that contains the data to be compressed.

allocator:BufferAllocator

the BufferAllocator that is used to allocate a new buffer (if needed) to write the compressed bytes too.

Returns:Buffer

the Buffer that contains the compressed data. The caller of this method takes ownership of the buffer. The return value will never be null.

Annotations
@Override
Exceptions
CompressionException:
thrown if an compression error was encountered or the compressor was closed already.
compressDataback to summary
private Buffer compressData(Buffer in, BufferAllocator allocator)
finishback to summary
public Buffer finish(BufferAllocator allocator)

Implements io.netty5.handler.codec.compression.Compressor.finish.

Doc from io.netty5.handler.codec.compression.Compressor.finish.

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.

Returns:Buffer

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.

Annotations
@Override
isClosedback to summary
public boolean isClosed()

Implements io.netty5.handler.codec.compression.Compressor.isClosed.

Doc from io.netty5.handler.codec.compression.Compressor.isClosed.

Return true if the decompressor was closed, false otherwise.

Returns:boolean

true if the decompressor was closed, false otherwise.

Annotations
@Override
isFinishedback to summary
public boolean isFinished()

Implements io.netty5.handler.codec.compression.Compressor.isFinished.

Doc from io.netty5.handler.codec.compression.Compressor.isFinished.

Returns true if the compressor was finished or closed. This might happen because someone explicit called finish(BufferAllocator) / close() or the compressor implementation did decide to close itself due a compression error which can't be recovered. After isFinished() returns true the compress(Buffer, BufferAllocator) method will just return an empty buffer without consuming anything from its input buffer.

Returns:boolean

true if the compressor was marked as finished, false otherwise.

Annotations
@Override
newFactoryback to summary
public static Supplier<FastLzCompressor> newFactory()

Creates a FastLZ compressor factory without checksum calculator and with auto detection of compression level.

Returns:Supplier<FastLzCompressor>

the factory.

newFactoryback to summary
public static Supplier<FastLzCompressor> newFactory(int level)

Creates a FastLZ compressor factory with specified compression level and without checksum calculator.

Parameters
level:int

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:Supplier<FastLzCompressor>

the factory.

newFactoryback to summary
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:boolean

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 java.util.zip.Adler32 for checksum calculation.

Returns:Supplier<FastLzCompressor>

the factory.

newFactoryback to summary
public static Supplier<FastLzCompressor> newFactory(int level, Checksum checksum)

Creates a FastLZ compressor factory with specified compression level and checksum calculator.

Parameters
level:int

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: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:Supplier<FastLzCompressor>

the factory.

io.netty5.handler.codec.compression back to summary

private final Enum FastLzCompressor.State

extends Enum<FastLzCompressor.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final FastLzCompressor.State
public static final FastLzCompressor.State
public static final FastLzCompressor.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static FastLzCompressor.State
public static FastLzCompressor.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLOSEDback to summary
public static final FastLzCompressor.State CLOSED
FINISHEDback to summary
public static final FastLzCompressor.State FINISHED
PROCESSINGback to summary
public static final FastLzCompressor.State PROCESSING

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static FastLzCompressor.State valueOf(String name)
valuesback to summary
public static FastLzCompressor.State[] values()