Example usage for org.apache.hadoop.io.compress Compressor reinit

List of usage examples for org.apache.hadoop.io.compress Compressor reinit

Introduction

In this page you can find the example usage for org.apache.hadoop.io.compress Compressor reinit.

Prototype

public void reinit(Configuration conf);

Source Link

Document

Prepare the compressor to be used in a new stream with settings defined in the given Configuration

Usage

From source file:org.apache.tajo.storage.compress.CodecPool.java

License:Apache License

/**
 * Get a {@link Compressor} for the given {@link CompressionCodec} from the
 * pool or a new one./* w  w  w  .  j av a2s  . co  m*/
 *
 * @param codec
 *          the <code>CompressionCodec</code> for which to get the
 *          <code>Compressor</code>
 * @param conf the <code>Configuration</code> object which contains confs for creating or reinit the compressor
 * @return <code>Compressor</code> for the given <code>CompressionCodec</code>
 *         from the pool or a new one
 */
public static Compressor getCompressor(CompressionCodec codec, Configuration conf) {
    Compressor compressor = borrow(COMPRESSOR_POOL, codec.getCompressorType());
    if (compressor == null) {
        compressor = codec.createCompressor();
        LOG.info("Got brand-new compressor [" + codec.getDefaultExtension() + "]");
    } else {
        compressor.reinit(conf);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Got recycled compressor");
        }
    }
    return compressor;
}