Helper method which performs decompression for snappy compressed values.
960723
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));
    }
673821
def compress(info):
    
    if PY3:
        file_obj = BytesIO()
    else:
        file_obj = StringIO()

    with zipfile.ZipFile(
            file_obj,
            mode='w',
            compression=zipfile.ZIP_DEFLATED) as zipper:
        for name, data in info.items():
            if hasattr(data, 'read'):
                # if we were passed a file object, read it
                data = data.read()
            zipper.writestr(name, data)
    file_obj.seek(0)
    compressed = file_obj.read()
    return compressed
1373615
def compressed_bytes2ibytes(compressed, size):
    
    decompressor = zlib.decompressobj(16 + zlib.MAX_WBITS)
    for i in range(0, mo_math.ceiling(len(compressed), size), size):
        try:
            block = compressed[i: i + size]
            yield decompressor.decompress(block)
        except Exception as e:
            Log.error("Not expected", e)
408107
def decompress(obj, return_type="bytes"):
    
    if isinstance(obj, binary_type):
        b = zlib.decompress(obj)
    elif isinstance(obj, string_types):
        b = zlib.decompress(base64.b64decode(obj.encode("utf-8")))
    else:
        raise TypeError("input cannot be anything other than str and bytes!")

    if return_type == "bytes":
        return b
    elif return_type == "str":
        return b.decode("utf-8")
    elif return_type == "obj":
        return pickle.loads(b)
    else:
        raise ValueError(
            "'return_type' has to be one of 'bytes', 'str' or 'obj'!")
2632
function processUncompressedData (o) {
  // Resets the packet counter back to zero
  o.lastSampleNumber = k.OBCIGanglionByteIdUncompressed;  // used to find dropped packets

  for (let i = 0; i < 4; i++) {
    o.decompressedSamples[0][i] = utilitiesModule.interpret24bitAsInt32(o.rawDataPacket.slice(1 + (i * 3), 1 + (i * 3) + 3));  // seed the decompressor
  }

  return [buildSample(0, o.decompressedSamples[0], o.sendCounts)];
}
463673
def _compress_content(self, content):
        """"""
        zbuf = StringIO()
        zfile = GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
        zfile.write(content.read())
        zfile.close()
        content.file = zbuf
        return content
459293
def decompress(data, format=FORMAT_AUTO, memlimit=None, filters=None):
    
    results = []
    while True:
        decomp = LZMADecompressor(format, memlimit, filters)
        try:
            res = decomp.decompress(data)
        except LZMAError:
            if results:
                break  # Leftover data is not a valid LZMA/XZ stream; ignore it.
            else:
                raise  # Error on the first iteration; bail out.
        results.append(res)
        if not decomp.eof:
            raise LZMAError("Compressed data ended before the "
                            "end-of-stream marker was reached")
        data = decomp.unused_data
        if not data:
            break
    return b"".join(results)
939074
def xz_decompress_stream(src):
    
    dec = lzma.LZMADecompressor()
    for block in src:
        decoded = dec.decompress(block)
        if decoded:
            yield decoded

    if dec.unused_data:  # pragma: nocover; can't figure out how to test this
        raise IOError('Read unused data at end of compressed stream')
580122
public static String decompressString(byte[] compressed) throws IOException {
        ByteArrayInputStream is = new ByteArrayInputStream(compressed);
        try (InputStream gis = new GZIPInputStream(is)) {
            return new String(Base64.decode(IOUtils.toByteArray(gis)), StandardCharsets.UTF_8);
        }
    }
552787
def decompress(self, data):
        
        chunks = []

        available_in = ffi.new("size_t *", len(data))
        in_buffer = ffi.new("uint8_t[]", data)
        next_in = ffi.new("uint8_t **", in_buffer)

        while True:
            # Allocate a buffer that's hopefully overlarge, but if it's not we
            # don't mind: we'll spin around again.
            buffer_size = 5 * len(data)
            available_out = ffi.new("size_t *", buffer_size)
            out_buffer = ffi.new("uint8_t[]", buffer_size)
            next_out = ffi.new("uint8_t **", out_buffer)

            rc = lib.BrotliDecoderDecompressStream(self._decoder,
                                                   available_in,
                                                   next_in,
                                                   available_out,
                                                   next_out,
                                                   ffi.NULL)

            # First, check for errors.
            if rc == lib.BROTLI_DECODER_RESULT_ERROR:
                error_code = lib.BrotliDecoderGetErrorCode(self._decoder)
                error_message = lib.BrotliDecoderErrorString(error_code)
                raise Error(
                    "Decompression error: %s" % ffi.string(error_message)
                )

            # Next, copy the result out.
            chunk = ffi.buffer(out_buffer, buffer_size - available_out[0])[:]
            chunks.append(chunk)

            if rc == lib.BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:
                assert available_in[0] == 0
                break
            elif rc == lib.BROTLI_DECODER_RESULT_SUCCESS:
                break
            else:
                # It's cool if we need more output, we just loop again.
                assert rc == lib.BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT

        return b''.join(chunks)
287289
function decompress(data) {
    var input = new Uint8Array(data);
    var output = [];

    var ip = 0;
    var op = 0;

    do {
        var ctrl = input[ip++];

        if (ctrl < (1 << 5)) { /* literal run */
            ctrl++;

            if (ip + ctrl > input.length) {
                throw new Error('Invalid input'); 
            }

            while (ctrl--) {
                output[op++] = input[ip++];
            }
        } else { /* back reference */
            var len = ctrl >> 5;
            var ref =  op - ((ctrl & 0x1f) << 8) - 1;

            if (ip >= input.length) {
                throw new Error('Invalid input');
            }

            if (len == 7) {
                len += input[ip++];

                if (ip >= input.length) {
                    throw new Error('Invalid input');
                }
            }

            ref -= input[ip++];

            if (ref < 0) {
                throw new Error('Invalid input');
            }

            len += 2;

            do {
                output[op++] = output[ref++];
            } while (--len);
        }
    } while (ip < input.length);

    // Return a Buffer if it exists (say in node), otherwise just
    // use a normal Uint8Array.
    if (typeof Buffer !== 'undefined') {
        return new Buffer(output);
    } else {
        var res = new Uint8Array(output.length);
        res.set(output);
        return res;
    }
}
65359
public void decompress(ByteBuffer src, ByteBuffer dest) {
    final int destLen = getDecompressedLength(src, src.position());
    final int read = decompressor.decompress(src, src.position() + 4, dest, dest.position(), destLen);
    src.position(src.position() + 4 + read);
    dest.position(dest.position() + destLen);
  }
1255024
def ungzip_data(input_data):
    """"""
    buf = StringIO(input_data)
    f = gzip.GzipFile(fileobj=buf)
    return f
1294717
private static String decompress(String str) throws EncoderException {
    /* First base64 decode the string */
    byte[] bytes = Base64.decodeBase64(str);
    GZIPInputStream zi = null;
    try {
      zi = new GZIPInputStream(new ByteArrayInputStream(bytes));
      InputStreamReader reader = new InputStreamReader(zi);
      BufferedReader in = new BufferedReader(reader);
      StringBuilder sb = new StringBuilder();
      String read;
      while ((read = in.readLine()) != null) {
        sb.append(read + "\n");
      }

      String molfile = sb.toString();
      reader.close();
      in.close();
      zi.close();
      return molfile;

    } catch (IOException e) {
      throw new EncoderException("Molfile could not be decompressed. " + str);
    } finally {
      IOUtils.closeQuietly(zi);
    }

  }
204260
def destroy_decompress(dinfo):
    """"""
    argtypes = [ctypes.POINTER(DecompressionInfoType)]
    OPENJPEG.opj_destroy_decompress.argtypes = argtypes
    OPENJPEG.opj_destroy_decompress(dinfo)
237340
def decompress(data_blocks):
    

    # Currently, with no max_length parameter to decompress,
    # this routine will do one yield per IDAT chunk: Not very
    # incremental.
    d = zlib.decompressobj()
    # Each IDAT chunk is passed to the decompressor, then any
    # remaining state is decompressed out.
    for data in data_blocks:
        # :todo: add a max_length argument here to limit output size.
        yield bytearray(d.decompress(data))
    yield bytearray(d.flush())
1244365
public static byte[] rawCompress(Object data, int byteSize)
            throws IOException
    {
        byte[] buf = new byte[Snappy.maxCompressedLength(byteSize)];
        int compressedByteSize = impl.rawCompress(data, 0, byteSize, buf, 0);
        byte[] result = new byte[compressedByteSize];
        System.arraycopy(buf, 0, result, 0, compressedByteSize);
        return result;
    }