当前位置: 首页>>代码示例>>Java>>正文


Java CompressionOutputStream类代码示例

本文整理汇总了Java中org.apache.hadoop.io.compress.CompressionOutputStream的典型用法代码示例。如果您正苦于以下问题:Java CompressionOutputStream类的具体用法?Java CompressionOutputStream怎么用?Java CompressionOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CompressionOutputStream类属于org.apache.hadoop.io.compress包,在下文中一共展示了CompressionOutputStream类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCompressionStream

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
@Override
public synchronized OutputStream createCompressionStream(
    OutputStream downStream, Compressor compressor,
    int downStreamBufferSize) throws IOException {
  if (!isSupported()) {
    throw new IOException(
        "LZO codec class not specified. Did you forget to set property "
            + CONF_LZO_CLASS + "?");
  }
  OutputStream bos1 = null;
  if (downStreamBufferSize > 0) {
    bos1 = new BufferedOutputStream(downStream, downStreamBufferSize);
  } else {
    bos1 = downStream;
  }
  conf.setInt("io.compression.codec.lzo.buffersize", 64 * 1024);
  CompressionOutputStream cos =
      codec.createOutputStream(bos1, compressor);
  BufferedOutputStream bos2 =
      new BufferedOutputStream(new FinishOnFlushCompressionStream(cos),
          DATA_OBUF_SIZE);
  return bos2;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:24,代码来源:Compression.java

示例2: create

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
@Override
public CompressionOutputStream create(OutputStream output, long timeout,
		TimeUnit unit) throws IOException, InterruptedException {
	if (hasCompressors) {
		Compressor compressor = compressorQueue.poll(timeout, unit);
		if (compressor == null) {
			if (adaptiveIncrement) {
				LOG.info("Adaptive increment, creating new compressor");
				compressor = codec.createCompressor();
			} else {
				return null;
			}
		}

		CompressionOutputStream cout = codec.createOutputStream(output,
				compressor);
		usedCompressors.put(cout, compressor);
		status.setCounter(COMPRESSOR_STR,
				compressorsUsedCount.getAndIncrement());
		return cout;

	} else {
		return codec.createOutputStream(output);
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:26,代码来源:CompressionPoolImpl.java

示例3: closeAndRelease

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
@Override
public void closeAndRelease(CompressionOutputStream cout) {

	try {
		// finish quietly
		cout.finish();
	} catch (IOException ioexp) {
		LOG.error(ioexp.toString(), ioexp);
	}

	IOUtils.closeQuietly(cout);

	if (hasCompressors) {
		Compressor comp = usedCompressors.remove(cout);
		comp.reset();
		compressorQueue.offer(comp);
		status.setCounter(COMPRESSOR_STR,
				compressorsUsedCount.decrementAndGet());
	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:22,代码来源:CompressionPoolImpl.java

示例4: copy

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
/**
 * 
 * @param source
 * @param dest
 * @param codec
 * @param compressor
 *            may be null
 * @param decomp
 *            may be null
 * @param mark
 * @return
 * @throws IOException
 */
public static final CompressionOutputStream copy(File source, File dest,
		CompressionCodec codec, Compressor compressor, Decompressor decomp,
		long mark) throws IOException {

	FileInputStream fileInput = new FileInputStream(source);
	CompressionInputStream in = (decomp == null) ? codec
			.createInputStream(fileInput) : codec.createInputStream(
			fileInput, decomp);

	FileOutputStream fileOut = new FileOutputStream(dest);
	CompressionOutputStream out = (compressor == null) ? codec
			.createOutputStream(fileOut) : codec.createOutputStream(
			fileOut, compressor);

	try {
		copy(in, out, mark);
		return out;
	} finally {
		IOUtils.closeQuietly(in);
		IOUtils.closeQuietly(fileInput);
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:36,代码来源:CompressionRollBackHelper.java

示例5: createCompressionStream

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
public OutputStream createCompressionStream(
    OutputStream downStream, Compressor compressor, int downStreamBufferSize)
    throws IOException {
  OutputStream bos1 = null;
  if (downStreamBufferSize > 0) {
    bos1 = new BufferedOutputStream(downStream, downStreamBufferSize);
  }
  else {
    bos1 = downStream;
  }
  CompressionOutputStream cos =
      createPlainCompressionStream(bos1, compressor);
  BufferedOutputStream bos2 =
      new BufferedOutputStream(new FinishOnFlushCompressionStream(cos),
          DATA_OBUF_SIZE);
  return bos2;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:18,代码来源:Compression.java

示例6: compress

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
public BytesInput compress(BytesInput bytes) throws IOException {
    final BytesInput compressedBytes;
    if (codec == null) {
        compressedBytes = bytes;
    } else {
        compressedOutBuffer.reset();
        if (compressor != null) {
            // null compressor for non-native gzip
            compressor.reset();
        }
        CompressionOutputStream cos = codec.createOutputStream(compressedOutBuffer, compressor);
        bytes.writeAllTo(cos);
        cos.finish();
        cos.close();
        compressedBytes = BytesInput.from(compressedOutBuffer);
    }
    return compressedBytes;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:19,代码来源:CodecFactory.java

示例7: compress

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
public BytesInput compress(BytesInput bytes)
        throws IOException
{
    final BytesInput compressedBytes;
    if (codec == null) {
        compressedBytes = bytes;
    }
    else {
        compressedOutBuffer.reset();
        if (compressor != null) {
            compressor.reset();
        }
        CompressionOutputStream outputStream = codec.createOutputStream(compressedOutBuffer, compressor);
        bytes.writeAllTo(outputStream);
        outputStream.finish();
        outputStream.close();
        compressedBytes = BytesInput.from(compressedOutBuffer);
    }
    return compressedBytes;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:ParquetCodecFactory.java

示例8: createCompressionStream

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
@Override
public synchronized OutputStream createCompressionStream(
    OutputStream downStream, Compressor compressor,
    int downStreamBufferSize) throws IOException {
  if (!isSupported()) {
    throw new IOException(
        "LZO codec class not specified. Did you forget to set property "
            + CONF_LZO_CLASS + "?");
  }
  OutputStream bos1 = null;
  if (downStreamBufferSize > 0) {
    bos1 = new BufferedOutputStream(downStream, downStreamBufferSize);
  } else {
    bos1 = downStream;
  }
  conf.setInt(IO_COMPRESSION_CODEC_LZO_BUFFERSIZE_KEY,
      IO_COMPRESSION_CODEC_LZO_BUFFERSIZE_DEFAULT);
  CompressionOutputStream cos =
      codec.createOutputStream(bos1, compressor);
  BufferedOutputStream bos2 =
      new BufferedOutputStream(new FinishOnFlushCompressionStream(cos),
          DATA_OBUF_SIZE);
  return bos2;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:25,代码来源:Compression.java

示例9: createCompressionStream

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
public OutputStream createCompressionStream(
    OutputStream downStream, Compressor compressor, int downStreamBufferSize)
    throws IOException {
  CompressionCodec codec = getCodec(conf);
  OutputStream bos1 = null;
  if (downStreamBufferSize > 0) {
    bos1 = new BufferedOutputStream(downStream, downStreamBufferSize);
  }
  else {
    bos1 = downStream;
  }
  ((Configurable)codec).getConf().setInt("io.file.buffer.size", 32 * 1024);
  CompressionOutputStream cos =
      codec.createOutputStream(bos1, compressor);
  BufferedOutputStream bos2 =
      new BufferedOutputStream(new FinishOnFlushCompressionStream(cos),
          DATA_OBUF_SIZE);
  return bos2;
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:20,代码来源:Compression.java

示例10: createCompressionStream

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
@Override
public synchronized OutputStream createCompressionStream(
    OutputStream downStream, Compressor compressor,
    int downStreamBufferSize) throws IOException {
  if (!isSupported()) {
    throw new IOException(
        "LZO codec class not specified. Did you forget to set property "
            + CONF_LZO_CLASS + "?");
  }
  OutputStream bos1 = null;
  if (downStreamBufferSize > 0) {
    bos1 = new BufferedOutputStream(downStream, downStreamBufferSize);
  } else {
    bos1 = downStream;
  }
  CompressionOutputStream cos =
      codec.createOutputStream(bos1, compressor);
  BufferedOutputStream bos2 =
      new BufferedOutputStream(new FinishOnFlushCompressionStream(cos),
          DATA_OBUF_SIZE);
  return bos2;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:23,代码来源:Compression.java

示例11: compress

import org.apache.hadoop.io.compress.CompressionOutputStream; //导入依赖的package包/类
@Override
public BytesInput compress(BytesInput bytes) throws IOException {
  final BytesInput compressedBytes;
  if (codec == null) {
    compressedBytes = bytes;
  } else {
    compressedOutBuffer.reset();
    if (compressor != null) {
      // null compressor for non-native gzip
      compressor.reset();
    }
    CompressionOutputStream cos = codec.createOutputStream(compressedOutBuffer, compressor);
    bytes.writeAllTo(cos);
    cos.finish();
    cos.close();
    compressedBytes = BytesInput.from(compressedOutBuffer);
  }
  return compressedBytes;
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:20,代码来源:CodecFactory.java


注:本文中的org.apache.hadoop.io.compress.CompressionOutputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。