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

public final class ZstdEncoder extends MessageToByteEncoder<io.netty.buffer.ByteBuf>
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

    Constructors
    Constructor
    Description
    Creates 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 Type
    Method
    Description
    protected io.netty.buffer.ByteBuf
    allocateBuffer(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf msg, boolean preferDirect)
    Allocate a ByteBuf which will be used as argument of MessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf).
    protected void
    encode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, io.netty.buffer.ByteBuf out)
    Encode a message into a ByteBuf.
    void
    flush(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
     

    Methods inherited from class io.netty.handler.codec.MessageToByteEncoder

    acceptOutboundMessage, isPreferDirect, write

    Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter

    bind, close, connect, deregister, disconnect, read

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, exceptionCaught, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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 use ZstdEncoder(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 compressionLevel
      maxEncodeSize - specifies the size of the largest compressed object
    • ZstdEncoder

      public ZstdEncoder(int compressionLevel, int blockSize, int maxEncodeSize)
      Parameters:
      compressionLevel - specifies the level of the compression
      blockSize - is used to calculate the compressionLevel
      maxEncodeSize - 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: MessageToByteEncoder
      Allocate a ByteBuf which will be used as argument of MessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf). Sub-classes may override this method to return ByteBuf with a perfect matching initialCapacity.
      Overrides:
      allocateBuffer in class MessageToByteEncoder<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: MessageToByteEncoder
      Encode a message into a ByteBuf. This method will be called for each written message that can be handled by this encoder.
      Specified by:
      encode in class MessageToByteEncoder<io.netty.buffer.ByteBuf>
      Parameters:
      ctx - the ChannelHandlerContext which this MessageToByteEncoder belongs to
      in - the message to encode
      out - the ByteBuf into which the encoded message will be written
    • flush

      public void flush(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      flush in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      flush in class io.netty.channel.ChannelOutboundHandlerAdapter
    • handlerAdded

      public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      handlerAdded in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerAdded in class io.netty.channel.ChannelHandlerAdapter
    • handlerRemoved

      public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      handlerRemoved in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerRemoved in class io.netty.channel.ChannelHandlerAdapter
      Throws:
      Exception