GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Overview
  • Use
  • Tree
  • Deprecated
  • Index
  • Search
  • Help
  • io.netty.handler.codec.compression
  • Lz4FrameEncoder

This view

  • Original page
  • New address

GeezerVison is showing netty.io — Lz4FrameEncoder (Netty API Reference (4.1.141.Final))

Class Lz4FrameEncoder

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToByteEncoder<ByteBuf>
io.netty.handler.codec.compression.Lz4FrameEncoder
All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler

public class Lz4FrameEncoder extends MessageToByteEncoder<ByteBuf>
Compresses a ByteBuf using the LZ4 format. See original LZ4 Github project and LZ4 block format for full description. Since the original LZ4 block format does not contains size of compressed block and size of original data this encoder uses format like LZ4 Java library written by Adrien Grand and approved by Yann Collet (author of original LZ4 library). * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Magic * Token * Compressed * Decompressed * Checksum * + * LZ4 compressed * * * * length * length * * * block * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  • Nested Class Summary

    Nested classes/interfaces inherited from interface ChannelHandler

    ChannelHandler.Sharable
    Modifier and Type
    Interface
    Description
    static @interface 
    ChannelHandler.Sharable
    Indicates that the same instance of the annotated ChannelHandler can be added to one or more ChannelPipelines multiple times without a race condition.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Lz4FrameEncoder()
    Creates the fastest LZ4 encoder with default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github.
    Lz4FrameEncoder(boolean highCompressor)
    Creates a new LZ4 encoder with hight or fast compression, default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github.
    Lz4FrameEncoder(net.jpountz.lz4.LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum)
    Creates a new customizable LZ4 encoder.
    Lz4FrameEncoder(net.jpountz.lz4.LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum, int maxEncodeSize)
    Creates a new customizable LZ4 encoder.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected ByteBuf
    allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect)
    Allocate a ByteBuf which will be used as argument of MessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf).
    ChannelFuture
    close()
    Close this Lz4FrameEncoder and so finish the encoding.
    void
    close(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.close(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    ChannelFuture
    close(ChannelPromise promise)
    Close this Lz4FrameEncoder and so finish the encoding.
    protected void
    encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out)
    Encode a message into a ByteBuf.
    void
    flush(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.flush() to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    handlerAdded(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    void
    handlerRemoved(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    boolean
    isClosed()
    Returns true if and only if the compressed stream has been finished.

    Methods inherited from class MessageToByteEncoder

    acceptOutboundMessage, isPreferDirect, write
    Modifier and Type
    Method
    Description
    boolean
    acceptOutboundMessage(Object msg)
    Returns true if the given message should be handled.
    protected boolean
    isPreferDirect()
     
    void
    write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
    Calls ChannelOutboundInvoker.write(Object, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelOutboundHandlerAdapter

    bind, connect, deregister, disconnect, read
    Modifier and Type
    Method
    Description
    void
    bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise)
    Calls ChannelOutboundInvoker.bind(SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
    Calls ChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    deregister(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.deregister(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    disconnect(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.disconnect(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    read(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.read() to forward to the next ChannelOutboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelHandlerAdapter

    ensureNotSharable, exceptionCaught, isSharable
    Modifier and Type
    Method
    Description
    protected void
    ensureNotSharable()
    Throws IllegalStateException if ChannelHandlerAdapter.isSharable() returns true
    void
    exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
    Deprecated.
    is part of ChannelInboundHandler
    boolean
    isSharable()
    Return true if the implementation is ChannelHandler.Sharable and so can be added to different ChannelPipelines.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Lz4FrameEncoder

      public Lz4FrameEncoder()
      Creates the fastest LZ4 encoder with default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github.
    • Lz4FrameEncoder

      public Lz4FrameEncoder(boolean highCompressor)
      Creates a new LZ4 encoder with hight or fast compression, default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github.
      Parameters:
      highCompressor - if true codec will use compressor which requires more memory and is slower but compresses more efficiently
    • Lz4FrameEncoder

      public Lz4FrameEncoder(net.jpountz.lz4.LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum)
      Creates a new customizable LZ4 encoder.
      Parameters:
      factory - user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the Unsafe
      highCompressor - if true codec will use compressor which requires more memory and is slower but compresses more efficiently
      blockSize - the maximum number of bytes to try to compress at once, must be >= 64 and invalid input: '<'= 32 M
      checksum - the Checksum instance to use to check data for integrity
    • Lz4FrameEncoder

      public Lz4FrameEncoder(net.jpountz.lz4.LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum, int maxEncodeSize)
      Creates a new customizable LZ4 encoder.
      Parameters:
      factory - user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the Unsafe
      highCompressor - if true codec will use compressor which requires more memory and is slower but compresses more efficiently
      blockSize - the maximum number of bytes to try to compress at once, must be >= 64 and invalid input: '<'= 32 M
      checksum - the Checksum instance to use to check data for integrity
      maxEncodeSize - the maximum size for an encode (compressed) buffer
  • Method Details

    • allocateBuffer

      protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, 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<ByteBuf>
    • encode

      protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception
      Encode a message into a ByteBuf. This method will be called for each written message that can be handled by this encoder. Encodes the input buffer into blockSize chunks in the output buffer. Data is only compressed and written once we hit the blockSize; else, it is copied into the backing buffer to await more data.
      Specified by:
      encode in class MessageToByteEncoder<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
      Throws:
      Exception - is thrown if an error occurs
    • flush

      public void flush(ChannelHandlerContext ctx) throws Exception
      Description copied from class: ChannelOutboundHandlerAdapter
      Calls ChannelHandlerContext.flush() to forward to the next ChannelOutboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.
      Specified by:
      flush in interface ChannelOutboundHandler
      Overrides:
      flush in class ChannelOutboundHandlerAdapter
      Parameters:
      ctx - the ChannelHandlerContext for which the flush operation is made
      Throws:
      Exception - thrown if an error occurs
    • isClosed

      public boolean isClosed()
      Returns true if and only if the compressed stream has been finished.
    • close

      public ChannelFuture close()
      Close this Lz4FrameEncoder and so finish the encoding. The returned ChannelFuture will be notified once the operation completes.
    • close

      public ChannelFuture close(ChannelPromise promise)
      Close this Lz4FrameEncoder and so finish the encoding. The given ChannelFuture will be notified once the operation completes and will also be returned.
    • close

      public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
      Description copied from class: ChannelOutboundHandlerAdapter
      Calls ChannelOutboundInvoker.close(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.
      Specified by:
      close in interface ChannelOutboundHandler
      Overrides:
      close in class ChannelOutboundHandlerAdapter
      Parameters:
      ctx - the ChannelHandlerContext for which the close operation is made
      promise - the ChannelPromise to notify once the operation completes
      Throws:
      Exception - thrown if an error occurs
    • handlerAdded

      public void handlerAdded(ChannelHandlerContext ctx)
      Description copied from class: ChannelHandlerAdapter
      Do nothing by default, sub-classes may override this method.
      Specified by:
      handlerAdded in interface ChannelHandler
      Overrides:
      handlerAdded in class ChannelHandlerAdapter
    • handlerRemoved

      public void handlerRemoved(ChannelHandlerContext ctx) throws Exception
      Description copied from class: ChannelHandlerAdapter
      Do nothing by default, sub-classes may override this method.
      Specified by:
      handlerRemoved in interface ChannelHandler
      Overrides:
      handlerRemoved in class ChannelHandlerAdapter
      Throws:
      Exception
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.