private void handleSnappyDecompression(final ChannelHandlerContext ctx, final FullBinaryMemcacheResponse response) {
        ByteBuf decompressed;
        if (response.content().readableBytes() > 0) {
            // we need to copy it on-heap...
            byte[] compressed = Unpooled.copiedBuffer(response.content()).array();
            try {
                decompressed = Unpooled.wrappedBuffer(Snappy.uncompress(compressed, 0, compressed.length));
            } catch (Exception ex) {
                throw new RuntimeException("Could not decode snappy-compressed value.", ex);
            }
        } else {
            decompressed = Unpooled.buffer(0);
        }


        response.content().release();
        response.setContent(decompressed);
        response.setTotalBodyLength(
            response.getExtrasLength()
                + response.getKeyLength()
                + decompressed.readableBytes()
        );
        response.setDataType((byte) (response.getDataType() & ~DATATYPE_SNAPPY));
    }
private void handleSnappyDecompression ( final ChannelHandlerContext ctx , final FullBinaryMemcacheResponse response ) { ByteBuf decompressed ; if ( response . content ( ) . readableBytes ( ) > 0 ) { byte [ ] compressed = Unpooled . copiedBuffer ( response . content ( ) ) . array ( ) ; try { decompressed = Unpooled . wrappedBuffer ( Snappy . uncompress ( compressed , 0 , compressed . length ) ) ; } catch ( Exception ex ) { throw new RuntimeException ( "Could not decode snappy-compressed value." , ex ) ; } } else { decompressed = Unpooled . buffer ( 0 ) ; } response . content ( ) . release ( ) ; response . setContent ( decompressed ) ; response . setTotalBodyLength ( response . getExtrasLength ( ) + response . getKeyLength ( ) + decompressed . readableBytes ( ) ) ; response . setDataType ( ( byte ) ( response . getDataType ( ) & ~ DATATYPE_SNAPPY ) ) ; }
Helper method which performs decompression for snappy compressed values.