Class ZstdDecoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.ByteToMessageDecoder
-
- io.netty.handler.codec.compression.ZstdDecoder
-
- All Implemented Interfaces:
ChannelHandler,ChannelInboundHandler
public final class ZstdDecoder extends ByteToMessageDecoder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classZstdDecoder.MutableByteBufInputStreamprivate static classZstdDecoder.StateCurrent state of stream.-
Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder
ByteToMessageDecoder.Cumulator
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private ZstdDecoder.StatecurrentStateprivate static intDEFAULT_MAX_FORWARD_BYTESstatic intDEFAULT_MAX_WINDOW_LOGDefault upper bound on theWindow_Logaccepted by the decoder.static intDEFAULT_MAXIMUM_ALLOCATION_SIZEDefault maximum size of a single output buffer, in bytes (4 MiB).(package private) static intDEFAULT_OUTPUT_BUFFER_SIZEprivate ZstdDecoder.MutableByteBufInputStreaminputStreamprivate static intMAX_WINDOW_LOGprivate intmaxForwardBytesprivate intmaxWindowLogprivate static intMIN_WINDOW_LOGprivate booleanneedsReadprivate intoutputBufferSizeprivate com.github.luben.zstd.ZstdInputStreamNoFinalizerzstdIs-
Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
-
-
Constructor Summary
Constructors Constructor Description ZstdDecoder()Creates a new decoder with theDEFAULT_MAXIMUM_ALLOCATION_SIZE, and theDEFAULT_MAX_WINDOW_LOGwindow log size.ZstdDecoder(int maximumAllocationSize)Creates a new decoder with the given maximum allocation size, and theDEFAULT_MAX_WINDOW_LOGwindow log size.ZstdDecoder(int maximumAllocationSize, int maxWindowLog)Creates a new decoder with an explicit upper bound on the acceptedWindow_Log.ZstdDecoder(int maximumAllocationSize, int maxWindowLog, int defaultMaxForwardBytes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelReadComplete(ChannelHandlerContext ctx)CallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline.private static voidcloseSilently(java.io.Closeable closeable)protected voiddecode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out)Decode the from oneByteBufto an other.voidhandlerAdded(ChannelHandlerContext ctx)Do nothing by default, sub-classes may override this method.protected voidhandlerRemoved0(ChannelHandlerContext ctx)Gets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.-
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
-
-
-
Field Detail
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
DEFAULT_MAX_WINDOW_LOG
public static final int DEFAULT_MAX_WINDOW_LOG
Default upper bound on theWindow_Logaccepted by the decoder.27corresponds to a 128 MiB decompression window.- See Also:
- Constant Field Values
-
MIN_WINDOW_LOG
private static final int MIN_WINDOW_LOG
- See Also:
- Constant Field Values
-
MAX_WINDOW_LOG
private static final int MAX_WINDOW_LOG
- See Also:
- Constant Field Values
-
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 Detail
-
ZstdDecoder
public ZstdDecoder()
Creates a new decoder with theDEFAULT_MAXIMUM_ALLOCATION_SIZE, and theDEFAULT_MAX_WINDOW_LOGwindow 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 theDEFAULT_MAX_WINDOW_LOGwindow 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 acceptedWindow_Log.- Parameters:
maximumAllocationSize- maximum size of a single output buffer.maxWindowLog- upper bound on theWindow_Logfield 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 Detail
-
decode
protected void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
Description copied from class:ByteToMessageDecoderDecode the from oneByteBufto an other. This method will be called till either the inputByteBufhas nothing to read when return from this method or till nothing was read from the inputByteBuf.- Specified by:
decodein classByteToMessageDecoder- Parameters:
ctx- theChannelHandlerContextwhich thisByteToMessageDecoderbelongs toin- theByteBuffrom which to read dataout- theListto which decoded messages should be added- Throws:
java.lang.Exception- is thrown if an error occurs
-
channelReadComplete
public void channelReadComplete(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelReadCompletein interfaceChannelInboundHandler- Overrides:
channelReadCompletein classByteToMessageDecoder- Throws:
java.lang.Exception
-
handlerAdded
public void handlerAdded(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerAddedin interfaceChannelHandler- Overrides:
handlerAddedin classChannelHandlerAdapter- Throws:
java.lang.Exception
-
handlerRemoved0
protected void handlerRemoved0(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ByteToMessageDecoderGets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.- Overrides:
handlerRemoved0in classByteToMessageDecoder- Throws:
java.lang.Exception
-
closeSilently
private static void closeSilently(java.io.Closeable closeable)
-
-