Class ZstdDecoder

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler

public final class ZstdDecoder extends ByteToMessageDecoder
Decompresses a compressed block ByteBuf using the Zstandard algorithm. See Zstandard.
  • Field Details

    • DEFAULT_MAX_FORWARD_BYTES

      private static final int DEFAULT_MAX_FORWARD_BYTES
    • DEFAULT_OUTPUT_BUFFER_SIZE

      static final int DEFAULT_OUTPUT_BUFFER_SIZE
      See Also:
    • DEFAULT_MAXIMUM_ALLOCATION_SIZE

      public static final int DEFAULT_MAXIMUM_ALLOCATION_SIZE
      Default maximum size of a single output buffer, in bytes (4 MiB).
      See Also:
    • DEFAULT_MAX_WINDOW_LOG

      public static final int DEFAULT_MAX_WINDOW_LOG
      Default upper bound on the Window_Log accepted by the decoder. 27 corresponds to a 128 MiB decompression window.
      See Also:
    • MIN_WINDOW_LOG

      private static final int MIN_WINDOW_LOG
      See Also:
    • MAX_WINDOW_LOG

      private static final int MAX_WINDOW_LOG
      See Also:
    • maxForwardBytes

      private final int maxForwardBytes
    • outputBufferSize

      private final int outputBufferSize
    • maxWindowLog

      private final int maxWindowLog
    • inputStream

      private final ZstdDecoder.MutableByteBufInputStream inputStream
    • zstdIs

      private com.github.luben.zstd.ZstdInputStreamNoFinalizer zstdIs
    • needsRead

      private boolean needsRead
    • currentState

      private ZstdDecoder.State currentState
  • Constructor Details

    • ZstdDecoder

      public ZstdDecoder()
      Creates a new decoder with the DEFAULT_MAXIMUM_ALLOCATION_SIZE, and the DEFAULT_MAX_WINDOW_LOG window log size.

      The window log size bounds the memory usage of the sliding window for ZSTD frame decompression. Frames declaring a larger window will be rejected to bound the memory the decoder may allocate per stream.

    • ZstdDecoder

      public ZstdDecoder(int maximumAllocationSize)
      Creates a new decoder with the given maximum allocation size, and the DEFAULT_MAX_WINDOW_LOG window log size.

      The window log size bounds the memory usage of the sliding window for ZSTD frame decompression. Frames declaring a larger window will be rejected to bound the memory the decoder may allocate per stream.

      Parameters:
      maximumAllocationSize - maximum size of a single output buffer.
    • ZstdDecoder

      public ZstdDecoder(int maximumAllocationSize, int maxWindowLog)
      Creates a new decoder with an explicit upper bound on the accepted Window_Log.
      Parameters:
      maximumAllocationSize - maximum size of a single output buffer.
      maxWindowLog - upper bound on the Window_Log field of incoming frames; must be in [10, 31]. Frames declaring a larger window will be rejected to bound the memory the decoder may allocate per stream.
    • ZstdDecoder

      ZstdDecoder(int maximumAllocationSize, int maxWindowLog, int defaultMaxForwardBytes)
  • Method Details