Re-compress the filtered data.

 All arguments are for Zlib. See the document of Zlib::Deflate.new for more detail.
510226
def compress(
      level = Zlib::DEFAULT_COMPRESSION,
      window_bits = Zlib::MAX_WBITS,
      mem_level = Zlib::DEF_MEM_LEVEL,
      strategy = Zlib::DEFAULT_STRATEGY
    )
      wrap_with_rewind(@compressed_data, @filtered_data) do
        z = Zlib::Deflate.new level, window_bits, mem_level, strategy
        until @filtered_data.eof? do
          buffer_size = 2 ** 16
          flush = Zlib::NO_FLUSH
          flush = Zlib::FINISH if @filtered_data.size - @filtered_data.pos < buffer_size
          @compressed_data << z.deflate(@filtered_data.read(buffer_size), flush)
        end
        z.finish
        z.close
        truncate_io @compressed_data
      end
      @is_compressed_data_modified = false
      self
    end
292135
def gzip_uncompress(data, truncated=False):
    '''
    '''
    decompressor = SimpleGzipDecompressor()
    inflated_data = decompressor.decompress(data)

    if not truncated:
        inflated_data += decompressor.flush()

    return inflated_data
1114635
def rm_compressed(ctx, dataset, kwargs):
    ""

    kwargs = parse_kwargs(kwargs)
    data(dataset, **ctx.obj).rm_compressed(**kwargs)
178105
def decompressBuffer(buffer):
    ""
    zbuf = cStringIO.StringIO(buffer)
    zfile = gzip.GzipFile(fileobj=zbuf)
    deflated = zfile.read()
    zfile.close()
    return deflated
1010027
def compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None):
    
    comp = LZMACompressor(format, check, preset, filters)
    return comp.compress(data) + comp.flush()
460662
function decompressSessionData(objData) {
    let amorphicOptions = AmorphicContext.amorphicOptions;
    if (amorphicOptions.compressSession && objData.data) {
        let buffer = new Buffer(objData.data);

        return zlib.inflateSync(buffer);
    }

    return objData;
}
1326126
def _compress(self):
        """"""

        # Don't compress too often
        now = time.time()
        if self._last_compression + self._compression_timer < now:
            self._last_compression = now
            for key in list(self._store.keys()):
                self.get(key)
4306
function Compressor(inflatedReady, deflatedReady) {
  this.inflatedReady = inflatedReady;
  this.deflatedReady = deflatedReady;
  this._inflate = inflater(chunk => this.inflatedReady(chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.length)));
  this._deflate = deflater(chunk => this.deflatedReady(chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.length)));
}
68940
public function decompress()
    {
        if ($this->state !== 'normal' && $this->collection) {
            $this->data = $this->applyDecompression($this->data);
            $this->state = 'normal';
        }
    }
121541
def compress_file(filename, content)
      zip.put_next_entry filename, nil, nil, Zip::Entry::DEFLATED, Zlib::BEST_COMPRESSION
      zip.write content.to_s
    end
1312137
def compress(samples, run_parallel):
    
    to_cram = []
    finished = []
    for data in [x[0] for x in samples]:
        if "cram" in dd.get_archive(data) or "cram-lossless" in dd.get_archive(data):
            to_cram.append([data])
        else:
            finished.append([data])
    crammed = run_parallel("archive_to_cram", to_cram)
    return finished + crammed
411174
def _safe_inflate data
      zi = Zlib::Inflate.new
      pos = 0; r = ''
      begin
        # save some memory by not using String#[] when not necessary
        r << zi.inflate(pos==0 ? data : data[pos..-1])
        if zi.total_in < data.size
          @extradata << data[zi.total_in..-1]
          puts "[?] #{@extradata.last.size} bytes of extra data after zlib stream".red if @verbose >= 1
        end
        # decompress OK
      rescue Zlib::BufError
        # tried to decompress, but got EOF - need more data
        puts "[!] #{$!.inspect}".red if @verbose >= -1
        # collect any remaining data in decompress buffer
        r << zi.flush_next_out
      rescue Zlib::DataError
        puts "[!] #{$!.inspect}".red if @verbose >= -1
        #p [pos, zi.total_in, zi.total_out, data.size, r.size]
        r << zi.flush_next_out
        # XXX TODO try to skip error and continue
#        printf "[d] pos=%d/%d t_in=%d t_out=%d bytes_ok=%d\n".gray, pos, data.size,
#          zi.total_in, zi.total_out, r.size
#        if pos < zi.total_in
#          pos = zi.total_in
#        else
#          pos += 1
#        end
#        pos = 0
#        retry if pos < data.size
      rescue Zlib::NeedDict
        puts "[!] #{$!.inspect}".red if @verbose >= -1
        # collect any remaining data in decompress buffer
        r << zi.flush_next_out
      end

      r == "" ? nil : r
    ensure
      zi.close if zi && !zi.closed?
    end
101974
public void compress() {
        IoBuffer tmp = IoBuffer.allocate(0);
        tmp.setAutoExpand(true);
        byte[] tmpData = new byte[data.limit()];
        data.position(0);
        data.get(tmpData);
        try (DeflaterOutputStream deflater = new DeflaterOutputStream(tmp.asOutputStream(), new Deflater(Deflater.BEST_COMPRESSION))) {
            deflater.write(tmpData);
            deflater.finish();
        } catch (IOException e) {
            //docs state that free is optional
            tmp.free();
            throw new RuntimeException("could not compress data", e);
        }
        data.free();
        data = tmp;
        data.flip();
        prepareIO();
    }
101619
def decompress(chunks, compression):
    

    if compression not in SUPPORTED_COMPRESSIONS:
        raise TypeError('Unsupported compression type: %s' % (compression,))

    de_compressor = DECOMPRESSOR_FACTORIES[compression]()
    try:
        for chunk in chunks:
            try:
                yield de_compressor.decompress(chunk)
            except OSError as err:
                # BZ2Decompressor: invalid data stream
                raise DecompressError(err) from None

        # BZ2Decompressor does not support flush() method.
        if hasattr(de_compressor, 'flush'):
            yield de_compressor.flush()

    except zlib.error as err:
        raise DecompressError(err) from None
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)
201291
def shrink_data(in_data, api_key=None):
    
    info = get_shrink_data_info(in_data, api_key)
    return info, get_shrunk_data(info)
787549
static final byte[] deflate(final byte[] in, final int len) {
		byte[] defBuf = new byte[len << 1];
		int payloadLength;
		synchronized (deflater) {
			deflater.reset();
			deflater.setInput(in, 0, len);
			deflater.finish();
			payloadLength = deflater.deflate(defBuf);
		}
		return resizeBuffer(defBuf, payloadLength);
	}