Class ZstdEncoder

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelOutboundHandler

    public final class ZstdEncoder
    extends io.netty.handler.codec.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
      ZstdEncoder()
      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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected io.netty.buffer.ByteBuf allocateBuffer​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf msg, boolean preferDirect)  
      protected void encode​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, io.netty.buffer.ByteBuf out)  
      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 interface io.netty.channel.ChannelHandler

        exceptionCaught
    • Constructor Detail

      • 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:
        blockSize - is used to calculate the compressionLevel
        maxEncodeSize - specifies the size of the largest compressed object
        compressionLevel - specifies the level of the compression
    • Method Detail

      • allocateBuffer

        protected io.netty.buffer.ByteBuf allocateBuffer​(io.netty.channel.ChannelHandlerContext ctx,
                                                         io.netty.buffer.ByteBuf msg,
                                                         boolean preferDirect)
        Overrides:
        allocateBuffer in class io.netty.handler.codec.MessageToByteEncoder<io.netty.buffer.ByteBuf>
      • encode

        protected void encode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.buffer.ByteBuf in,
                              io.netty.buffer.ByteBuf out)
        Specified by:
        encode in class io.netty.handler.codec.MessageToByteEncoder<io.netty.buffer.ByteBuf>
      • 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