/** * Let go of block compressor and compressing stream gotten in call {@link * #getCompressingStream}. * * @param dos * * @return How much was written on this stream since it was taken out. * * @see #getCompressingStream() * * @throws IOException */ private int releaseCompressingStream(final DataOutputStream dos) throws IOException { dos.flush(); this.compressAlgo.returnCompressor(this.compressor); this.compressor = null; return dos.size(); }
public static void testCompression(Compression.Algorithm algo) throws IOException { if (compressionTestResults[algo.ordinal()] != null) { if (compressionTestResults[algo.ordinal()]) { return ; // already passed test, dont do it again. } else { // failed. throw new IOException("Compression algorithm '" + algo.getName() + "'" + " previously failed test."); } } Configuration conf = HBaseConfiguration.create(); try { Compressor c = algo.getCompressor(); algo.returnCompressor(c); compressionTestResults[algo.ordinal()] = true; // passes } catch (Throwable t) { compressionTestResults[algo.ordinal()] = false; // failure throw new IOException(t); } }
/** * Releases the compressor this writer uses to compress blocks into the * compressor pool. Needs to be called before the writer is discarded. */ public void releaseCompressor() { if (compressor != null) { compressAlgo.returnCompressor(compressor); compressor = null; } }