Class ZstdEncoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToByteEncoder<io.netty.buffer.ByteBuf>
io.netty.handler.codec.compression.ZstdEncoder
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelOutboundHandler
Compresses a
ByteBuf using the Zstandard algorithm.
See Zstandard.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Zstd encoder.ZstdEncoder(int compressionLevel) Creates a new Zstd encoder.ZstdEncoder(int blockSize, int maxEncodeSize) Creates a new Zstd encoder.ZstdEncoder(int compressionLevel, int blockSize, int maxEncodeSize) -
Method Summary
Modifier and TypeMethodDescriptionprotected io.netty.buffer.ByteBufallocateBuffer(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf msg, boolean preferDirect) Allocate aByteBufwhich will be used as argument ofMessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf).protected voidencode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, io.netty.buffer.ByteBuf out) Encode a message into aByteBuf.voidflush(io.netty.channel.ChannelHandlerContext ctx) voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx) voidhandlerRemoved(io.netty.channel.ChannelHandlerContext ctx) Methods inherited from class io.netty.handler.codec.MessageToByteEncoder
acceptOutboundMessage, isPreferDirect, writeMethods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, readMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught
-
Constructor Details
-
ZstdEncoder
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 useZstdEncoder(int,int)constructor -
ZstdEncoder
public ZstdEncoder(int compressionLevel) Creates a new Zstd encoder.- Parameters:
compressionLevel- specifies the level of the compression
-
ZstdEncoder
public ZstdEncoder(int blockSize, int maxEncodeSize) Creates a new Zstd encoder.- Parameters:
blockSize- is used to calculate the compressionLevelmaxEncodeSize- specifies the size of the largest compressed object
-
ZstdEncoder
public ZstdEncoder(int compressionLevel, int blockSize, int maxEncodeSize) - Parameters:
compressionLevel- specifies the level of the compressionblockSize- is used to calculate the compressionLevelmaxEncodeSize- specifies the size of the largest compressed object
-
-
Method Details
-
allocateBuffer
protected io.netty.buffer.ByteBuf allocateBuffer(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf msg, boolean preferDirect) Description copied from class:MessageToByteEncoderAllocate aByteBufwhich will be used as argument ofMessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf). Sub-classes may override this method to returnByteBufwith a perfect matchinginitialCapacity.- Overrides:
allocateBufferin classMessageToByteEncoder<io.netty.buffer.ByteBuf>
-
encode
protected void encode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, io.netty.buffer.ByteBuf out) Description copied from class:MessageToByteEncoderEncode a message into aByteBuf. This method will be called for each written message that can be handled by this encoder.- Specified by:
encodein classMessageToByteEncoder<io.netty.buffer.ByteBuf>- Parameters:
ctx- theChannelHandlerContextwhich thisMessageToByteEncoderbelongs toin- the message to encodeout- theByteBufinto which the encoded message will be written
-
flush
public void flush(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
flushin interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
flushin classio.netty.channel.ChannelOutboundHandlerAdapter
-
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter
-
handlerRemoved
- Specified by:
handlerRemovedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerRemovedin classio.netty.channel.ChannelHandlerAdapter- Throws:
Exception
-