private Deflater getDeflater() { if (null == deflater) { deflater = new Deflater(compressionLevel, nowrap); } deflater.reset(); return deflater; }
void reset() { crc.reset(); def.reset(); sourcePayloadLength = 0; writtenToOutputStreamForLastEntry = 0; }
private Deflater getDeflater() { if (null == deflater) deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true); deflater.reset(); return deflater; }
private Deflater getDeflater() { if (null == deflater) { deflater = new Deflater(compressionLevel, nowrap); } deflater.reset(); return deflater; }
public void resetState() throws IOException { def.reset(); crc.reset(); out.write(GZIP_HEADER); }
@Override public synchronized void write(byte[] buf, int off, int len) throws IOException { if (reset) { def.reset(); crc.reset(); out.write(GZIP_HEADER); reset = false; } super.write(buf, off, len); }
/** * Compresses the currently buffered chunk of data and sends it to the output stream * * @throws IOException if issues occur writing to stream */ protected void compressAndWrite() throws IOException { if (bufferIndex <= 0) { return; } deflater.setInput(buffer, 0, bufferIndex); deflater.finish(); final int compressedBytes = deflater.deflate(compressed); writeChunkHeader(compressedBytes); out.write(compressed, 0, compressedBytes); bufferIndex = 0; deflater.reset(); }
deflater.reset();
@Override public ByteBuf encode(ByteBuf source) { byte[] array; int length = source.readableBytes(); int sizeEstimate = (int) Math.ceil(source.readableBytes() * 1.001) + 14; ByteBuf compressed = PooledByteBufAllocator.DEFAULT.heapBuffer(sizeEstimate); int offset = 0; if (source.hasArray()) { array = source.array(); offset = source.arrayOffset() + source.readerIndex(); } else { // If it's a direct buffer, we need to copy it array = new byte[length]; source.getBytes(source.readerIndex(), array); } Deflater deflater = this.deflater.get(); deflater.reset(); deflater.setInput(array, offset, length); while (!deflater.needsInput()) { deflate(deflater, compressed); } return compressed; }
@Override public void compress(byte[] bytes, int off, int len, DataOutput out) throws IOException { compressor.reset(); compressor.setInput(bytes, off, len); compressor.finish(); if (compressor.needsInput()) { // no output assert len == 0 : len; out.writeVInt(0); return; } int totalCount = 0; for (;;) { final int count = compressor.deflate(compressed, totalCount, compressed.length - totalCount); totalCount += count; assert totalCount <= compressed.length; if (compressor.finished()) { break; } else { compressed = ArrayUtil.grow(compressed); } } out.writeVInt(totalCount); out.writeBytes(compressed, totalCount); }
outputBuffer.put((byte) 0); if (!compressContextTakeover) { compress.reset();
try { deflater=deflater_pool.take(); deflater.reset(); deflater.setInput(payload, msg.getOffset(), length); deflater.finish();
deflater.reset();
deflater.reset();
/** * Reinitialze everything so we can write a brand new gzip output stream * again. */ public void reset() { if (DEBUG) System.out.println("Resetting (writtenSize=" + _writtenSize + ")"); def.reset(); _crc32.reset(); _writtenSize = 0; _headerWritten = false; }
entry.entry.setCrc(crc); def.reset(); } else if (raf == null) { if (entry.entry.getCrc() != crc) {
def.reset(); done = false;
entry.entry.setCrc(crc); def.reset(); } else if (raf == null) { if (entry.entry.getCrc() != crc) {
void beginObject(int objectType, long length) throws IOException { crc32.reset(); deflater.reset(); write(hdrBuf, 0, encodeTypeSize(objectType, length)); }
private void writeWholeObjectDeflate(PackOutputStream out, final ObjectToPack otp) throws IOException { final Deflater deflater = deflater(); final ObjectLoader ldr = reader.open(otp, otp.getType()); crc32.reset(); otp.setOffset(out.length()); out.writeHeader(otp, ldr.getSize()); deflater.reset(); DeflaterOutputStream dst = new DeflaterOutputStream(out, deflater); ldr.copyTo(dst); dst.finish(); }