/// <exception cref="System.IO.IOException"/> 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 { if (Log.IsDebugEnabled()) { Log.Debug("Got a compressor: " + compressor.GetHashCode()); } } compressor.Reset(); } return(compressor); } return(null); }
/// <exception cref="System.IO.IOException"/> public Writer(Configuration conf, FSDataOutputStream @out, Type keyClass, Type valueClass , CompressionCodec codec, Counters.Counter writesCounter, bool ownOutputStream) { this.writtenRecordsCounter = writesCounter; this.checksumOut = new IFileOutputStream(@out); this.rawOut = @out; this.start = this.rawOut.GetPos(); if (codec != null) { this.compressor = CodecPool.GetCompressor(codec); if (this.compressor != null) { this.compressor.Reset(); this.compressedOut = codec.CreateOutputStream(checksumOut, compressor); this.@out = new FSDataOutputStream(this.compressedOut, null); this.compressOutput = true; } else { Log.Warn("Could not obtain compressor from CodecPool"); this.@out = new FSDataOutputStream(checksumOut, null); } } else { this.@out = new FSDataOutputStream(checksumOut, null); } this.keyClass = keyClass; this.valueClass = valueClass; if (keyClass != null) { SerializationFactory serializationFactory = new SerializationFactory(conf); this.keySerializer = serializationFactory.GetSerializer(keyClass); this.keySerializer.Open(buffer); this.valueSerializer = serializationFactory.GetSerializer(valueClass); this.valueSerializer.Open(buffer); } this.ownOutputStream = ownOutputStream; }