ZstdEncoder extends MessageToByteEncoder<ByteBuf> { @VisibleForTesting protected static int compressionLevel(int blockSize) { if (blockSize < MIN_BLOCK_SIZE || blockSize > MAX_BLOCK_SIZE) { throw new IllegalArgumentException(String.format( "blockSize: %d (expected: %d-%d)", blockSize, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE)); } int compressionLevel = 32 - Integer.numberOfLeadingZeros(blockSize - 1); compressionLevel = Math.max(0, compressionLevel - COMPRESSION_LEVEL_BASE); return compressionLevel; } ZstdEncoder();  ZstdEncoder(int blockSize, int maxEncodeSize); @Override void flush(final ChannelHandlerContext ctx); boolean isClosed(); ChannelFuture close(); ChannelFuture close(final ChannelPromise promise); @Override void close(final ChannelHandlerContext ctx, final ChannelPromise promise); @Override void handlerAdded(ChannelHandlerContext ctx); @Override void handlerRemoved(ChannelHandlerContext ctx);  }
@Ignore @Test public void testCompressionLevel() { logger.info("{}", ZstdEncoder.compressionLevel(64)); logger.info("{}", ZstdEncoder.compressionLevel(DEFAULT_BLOCK_SIZE)); int compressionLevel = ZstdEncoder.compressionLevel(DEFAULT_BLOCK_SIZE); int blockType = BLOCK_TYPE_NON_COMPRESSED; logger.info("{}", (byte) (blockType | compressionLevel)); blockType = BLOCK_TYPE_COMPRESSED; logger.info("{}", (byte) (blockType | compressionLevel)); logger.info("{}", 0xF0); byte token = (byte) (BLOCK_TYPE_NON_COMPRESSED | compressionLevel); logger.info("{}", token & 0xF0); token = (byte) (BLOCK_TYPE_COMPRESSED | compressionLevel); logger.info("{}", token & 0xF0); token = (byte) (BLOCK_TYPE_COMPRESSED); logger.info("{}", token & 0xF0); token = (byte) (BLOCK_TYPE_NON_COMPRESSED); logger.info("{}", token & 0xF0); logger.info("{}", BLOCK_TYPE_COMPRESSED); logger.info("{}", BLOCK_TYPE_NON_COMPRESSED); }