Top Description Fields Constructors Methods
io.netty.handler.codec.compression

public final Class ZstdEncoder

extends MessageToByteEncoder<ByteBuf>
Class Inheritance
Imports
com.github.luben.zstd.Zstd, io.netty.buffer.ByteBuf, .Unpooled, io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.EncoderException, .MessageToByteEncoder, io.netty.util.internal.ObjectUtil, java.nio.ByteBuffer

Compresses a ByteBuf using the Zstandard algorithm. See Zstandard.

Field Summary

Modifier and TypeField and Description
private final int
private ByteBuf
private final int
private final int

Constructor Summary

AccessConstructor and Description
public
ZstdEncoder()

Creates a new Zstd encoder.

public
ZstdEncoder(int
specifies the level of the compression
compressionLevel
)

Creates a new Zstd encoder.

public
ZstdEncoder(int
is used to calculate the compressionLevel
blockSize
,
int
specifies the size of the largest compressed object
maxEncodeSize
)

Creates a new Zstd encoder.

public
ZstdEncoder(int
specifies the level of the compression
compressionLevel
,
int
is used to calculate the compressionLevel
blockSize
,
int
specifies the size of the largest compressed object
maxEncodeSize
)

Method Summary

Modifier and TypeMethod and Description
protected ByteBuf
protected void
encode(ChannelHandlerContext ctx, ByteBuf
the message to encode
in
,
ByteBuf
the ByteBuf into which the encoded message will be written
out
)

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf.
public void
private void
public void
handlerAdded(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.
public void
handlerRemoved(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerRemoved.

Implements io.netty.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.
Inherited from io.netty.handler.codec.MessageToByteEncoder:
acceptOutboundMessageisPreferDirectwrite

Field Detail

blockSizeback to summary
private final int blockSize
bufferback to summary
private ByteBuf buffer
compressionLevelback to summary
private final int compressionLevel
maxEncodeSizeback to summary
private final int maxEncodeSize

Constructor Detail

ZstdEncoderback to summary
public ZstdEncoder()

Creates a new Zstd encoder. Please note that if you use the default constructor, the default BLOCK_SIZE and MAX_BLOCK_SIZE will be used. If you want to specify BLOCK_SIZE and MAX_BLOCK_SIZE yourself, please use ZstdEncoder(int, int) constructor

ZstdEncoderback to summary
public ZstdEncoder(int compressionLevel)

Creates a new Zstd encoder.

Parameters
compressionLevel:int

specifies the level of the compression

ZstdEncoderback to summary
public ZstdEncoder(int blockSize, int maxEncodeSize)

Creates a new Zstd encoder.

Parameters
blockSize:int

is used to calculate the compressionLevel

maxEncodeSize:int

specifies the size of the largest compressed object

ZstdEncoderback to summary
public ZstdEncoder(int compressionLevel, int blockSize, int maxEncodeSize)
Parameters
compressionLevel:int

specifies the level of the compression

blockSize:int

is used to calculate the compressionLevel

maxEncodeSize:int

specifies the size of the largest compressed object

Method Detail

allocateBufferback to summary
protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect)

Overrides io.netty.handler.codec.MessageToByteEncoder.allocateBuffer.

Doc from io.netty.handler.codec.MessageToByteEncoder.allocateBuffer.

Allocate a ByteBuf which will be used as argument of encode(ChannelHandlerContext, I, ByteBuf). Sub-classes may override this method to return ByteBuf with a perfect matching initialCapacity.

Annotations
@Override
encodeback to summary
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out)

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Doc from io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf. This method will be called for each written message that can be handled by this encoder.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToByteEncoder belongs to

in:ByteBuf

the message to encode

out:ByteBuf

the ByteBuf into which the encoded message will be written

Annotations
@Override
flushback to summary
public void flush(final ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelOutboundHandlerAdapter.flush.

Implements io.netty.channel.ChannelOutboundHandler.flush.

Doc from io.netty.channel.ChannelOutboundHandlerAdapter.flush.

Calls ChannelHandlerContext#flush() to forward to the next ChannelOutboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Parameters
ctx:ChannelHandlerContext

Doc from io.netty.channel.ChannelOutboundHandler.flush.

the ChannelHandlerContext for which the flush operation is made

Annotations
@Override
flushBufferedDataback to summary
private void flushBufferedData(ByteBuf out)
handlerAddedback to summary
public void handlerAdded(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Doc from io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Annotations
@Override
handlerRemovedback to summary
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.channel.ChannelHandlerAdapter.handlerRemoved.

Implements io.netty.channel.ChannelHandler.handlerRemoved.

Doc from io.netty.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.

Annotations
@Override