@Override public void resetState() throws IOException { compressor.reset(); }
/** * Return the {@link Compressor} to the pool. * * @param compressor * the <code>Compressor</code> to be returned to the pool */ public static void returnCompressor(Compressor compressor) { if (compressor == null) { return; } compressor.reset(); payback(COMPRESSOR_POOL, compressor); }
/** * Return the {@link Compressor} to the pool. * * @param compressor * the <code>Compressor</code> to be returned to the pool */ public static void returnCompressor(Compressor compressor) { if (compressor == null) { return; } compressor.reset(); payback(COMPRESSOR_POOL, compressor); }
@Override public CompressedSliceOutput get() { try { compressor.reset(); compressedOutput.reset(); CompressionOutputStream compressionStream = codec.createOutputStream(compressedOutput, compressor); return new CompressedSliceOutput(compressionStream, compressedOutput, this, () -> {}); } catch (IOException e) { throw new UncheckedIOException(e); } } }
/** * Return the {@link Compressor} to the pool. * * @param compressor the <code>Compressor</code> to be returned to the pool */ public static void returnCompressor(Compressor compressor) { if (compressor == null) { return; } // if the compressor can't be reused, don't pool it. if (compressor.getClass().isAnnotationPresent(DoNotPool.class)) { return; } compressor.reset(); if (payback(compressorPool, compressor)) { updateLeaseCount(compressorCounts, compressor, -1); } }
public Compressor getCompressor() { CompressionCodec codec = getCodec(conf); if (codec != null) { Compressor compressor = CodecPool.getCompressor(codec); if (LOG.isTraceEnabled()) LOG.trace("Retrieved compressor " + compressor + " from pool."); if (compressor != null) { if (compressor.finished()) { // Somebody returns the compressor to CodecPool but is still using it. LOG.warn("Compressor obtained from CodecPool is already finished()"); } compressor.reset(); } return compressor; } return null; }
@Override public CompressedSliceOutput get() { try { compressor.reset(); bufferedOutput.reset(); CompressionOutputStream compressionStream = codec.createOutputStream(bufferedOutput, compressor); return new CompressedSliceOutput(compressionStream, bufferedOutput, this, () -> CodecPool.returnCompressor(compressor)); } catch (IOException e) { throw new UncheckedIOException(e); } } }
public Compressor getCompressor() throws IOException { CompressionCodec codec = getCodec(); if (codec != null) { Compressor compressor = CodecPool.getCompressor(codec); if (compressor != null) { if (compressor.finished()) { // Somebody returns the compressor to CodecPool but is still using // it. LOG.warn("Compressor obtained from CodecPool already finished()"); } else { if(LOG.isDebugEnabled()) { LOG.debug("Got a compressor: " + compressor.hashCode()); } } /** * Following statement is necessary to get around bugs in 0.18 where a * compressor is referenced after returned back to the codec pool. */ compressor.reset(); } return compressor; } return null; }
compressor.reset();
public Compressor getCompressor() { CompressionCodec codec = getCodec(); if (codec != null) { Compressor compressor = CodecPool.getCompressor(codec); if (compressor != null) { if (compressor.finished()) { // Somebody returns the compressor to CodecPool but is still using // it. log.warn("Compressor obtained from CodecPool already finished()"); } else { log.debug("Got a compressor: {}", compressor.hashCode()); } /** * Following statement is necessary to get around bugs in 0.18 where a compressor is * referenced after returned back to the codec pool. */ compressor.reset(); } return compressor; } return null; }
@Override public void resetState() throws IOException { compressor.reset(); }
@Override public void resetState() throws IOException { compressor.reset(); }
@Override public void resetState() throws IOException { compressor.reset(); }
@Override public void resetState() throws IOException { compressor.reset(); }
/** * Return the {@link Compressor} to the pool. * * @param compressor the <code>Compressor</code> to be returned to the pool */ public static void returnCompressor(Compressor compressor) { if (compressor == null) { return; } compressor.reset(); payback(compressorPool, compressor); }
/** * Return the {@link Compressor} to the pool. * * @param compressor the <code>Compressor</code> to be returned to the pool */ public static void returnCompressor(Compressor compressor) { if (compressor == null) { return; } compressor.reset(); payback(compressorPool, compressor); }
/** * Return the {@link Compressor} to the pool. * * @param compressor * the <code>Compressor</code> to be returned to the pool */ public static void returnCompressor(Compressor compressor) { if (compressor == null) { return; } compressor.reset(); payback(COMPRESSOR_POOL, compressor); }
private void flushBuffer() throws IOException { if (_bufferPosition > 0) { _compressor.reset(); _compressor.setInput(_buffer, 0, _bufferPosition); _compressor.finish(); long filePointer = _output.getFilePointer(); int length = _compressor.compress(_compressedBuffer, 0, _compressedBuffer.length); _tmpOutput.writeLong(filePointer); _blockCount++; _output.writeBytes(_compressedBuffer, 0, length); } }
private void flushBuffer() throws IOException { if (_bufferPosition > 0) { _compressor.reset(); _compressor.setInput(_buffer, 0, _bufferPosition); _compressor.finish(); long filePointer = _output.getFilePointer(); int length = _compressor.compress(_compressedBuffer, 0, _compressedBuffer.length); _tmpOutput.writeVLong(filePointer); _tmpOutput.writeVInt(length); _blockCount++; _output.writeBytes(_compressedBuffer, 0, length); } }