當前位置: 首頁>>代碼示例>>Java>>正文


Java Decompressor類代碼示例

本文整理匯總了Java中org.apache.hadoop.io.compress.Decompressor的典型用法代碼示例。如果您正苦於以下問題:Java Decompressor類的具體用法?Java Decompressor怎麽用?Java Decompressor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Decompressor類屬於org.apache.hadoop.io.compress包,在下文中一共展示了Decompressor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDecompressor

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
public Decompressor getDecompressor() throws IOException {
  CompressionCodec codec = getCodec();
  if (codec != null) {
    Decompressor decompressor = CodecPool.getDecompressor(codec);
    if (decompressor != null) {
      if (decompressor.finished()) {
        // Somebody returns the decompressor to CodecPool but is still using
        // it.
        LOG.warn("Deompressor obtained from CodecPool already finished()");
      } else {
        if(LOG.isDebugEnabled()) {
          LOG.debug("Got a decompressor: " + decompressor.hashCode());
        }
      }
      /**
       * Following statement is necessary to get around bugs in 0.18 where a
       * decompressor is referenced after returned back to the codec pool.
       */
      decompressor.reset();
    }
    return decompressor;
  }

  return null;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:26,代碼來源:Compression.java

示例2: testZlibCompressorDecompressorWithConfiguration

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
@Test
public void testZlibCompressorDecompressorWithConfiguration() {
  Configuration conf = new Configuration();
  if (ZlibFactory.isNativeZlibLoaded(conf)) {
    byte[] rawData;
    int tryNumber = 5;
    int BYTE_SIZE = 10 * 1024;
    Compressor zlibCompressor = ZlibFactory.getZlibCompressor(conf);
    Decompressor zlibDecompressor = ZlibFactory.getZlibDecompressor(conf);
    rawData = generate(BYTE_SIZE);
    try {
      for (int i = 0; i < tryNumber; i++)
        compressDecompressZlib(rawData, (ZlibCompressor) zlibCompressor,
            (ZlibDecompressor) zlibDecompressor);
      zlibCompressor.reinit(conf);
    } catch (Exception ex) {
      fail("testZlibCompressorDecompressorWithConfiguration ex error " + ex);
    }
  } else {
    assertTrue("ZlibFactory is using native libs against request",
        ZlibFactory.isNativeZlibLoaded(conf));
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:24,代碼來源:TestZlibCompressorDecompressor.java

示例3: testZlibCompressorDecompressorWithCompressionLevels

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
@Test
public void testZlibCompressorDecompressorWithCompressionLevels() {
  Configuration conf = new Configuration();
  conf.set("zlib.compress.level","FOUR");
  if (ZlibFactory.isNativeZlibLoaded(conf)) {
    byte[] rawData;
    int tryNumber = 5;
    int BYTE_SIZE = 10 * 1024;
    Compressor zlibCompressor = ZlibFactory.getZlibCompressor(conf);
    Decompressor zlibDecompressor = ZlibFactory.getZlibDecompressor(conf);
    rawData = generate(BYTE_SIZE);
    try {
      for (int i = 0; i < tryNumber; i++)
        compressDecompressZlib(rawData, (ZlibCompressor) zlibCompressor,
                (ZlibDecompressor) zlibDecompressor);
      zlibCompressor.reinit(conf);
    } catch (Exception ex) {
      fail("testZlibCompressorDecompressorWithConfiguration ex error " + ex);
    }
  } else {
    assertTrue("ZlibFactory is using native libs against request",
            ZlibFactory.isNativeZlibLoaded(conf));
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:25,代碼來源:TestZlibCompressorDecompressor.java

示例4: testZlibCompressorDecompressorSetDictionary

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
@Test
public void testZlibCompressorDecompressorSetDictionary() {
  Configuration conf = new Configuration();
  if (ZlibFactory.isNativeZlibLoaded(conf)) {
    Compressor zlibCompressor = ZlibFactory.getZlibCompressor(conf);
    Decompressor zlibDecompressor = ZlibFactory.getZlibDecompressor(conf);

    checkSetDictionaryNullPointerException(zlibCompressor);
    checkSetDictionaryNullPointerException(zlibDecompressor);

    checkSetDictionaryArrayIndexOutOfBoundsException(zlibDecompressor);
    checkSetDictionaryArrayIndexOutOfBoundsException(zlibCompressor);
  } else {
    assertTrue("ZlibFactory is using native libs against request",
        ZlibFactory.isNativeZlibLoaded(conf));
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:18,代碼來源:TestZlibCompressorDecompressor.java

示例5: testZlibCompressorDecompressorWithConfiguration

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
@Test
public void testZlibCompressorDecompressorWithConfiguration() {
  Configuration conf = new Configuration();
  conf.setBoolean(CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY, true);
  if (ZlibFactory.isNativeZlibLoaded(conf)) {
    byte[] rawData;
    int tryNumber = 5;
    int BYTE_SIZE = 10 * 1024;
    Compressor zlibCompressor = ZlibFactory.getZlibCompressor(conf);
    Decompressor zlibDecompressor = ZlibFactory.getZlibDecompressor(conf);
    rawData = generate(BYTE_SIZE);
    try {
      for (int i = 0; i < tryNumber; i++)
        compressDecompressZlib(rawData, (ZlibCompressor) zlibCompressor,
            (ZlibDecompressor) zlibDecompressor);
      zlibCompressor.reinit(conf);
    } catch (Exception ex) {
      fail("testZlibCompressorDecompressorWithConfiguration ex error " + ex);
    }
  } else {
    assertTrue("ZlibFactory is using native libs against request",
        ZlibFactory.isNativeZlibLoaded(conf));
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:TestZlibCompressorDecompressor.java

示例6: testZlibCompressorDecompressorSetDictionary

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
@Test
public void testZlibCompressorDecompressorSetDictionary() {
  Configuration conf = new Configuration();
  conf.setBoolean(CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY, true);
  if (ZlibFactory.isNativeZlibLoaded(conf)) {
    Compressor zlibCompressor = ZlibFactory.getZlibCompressor(conf);
    Decompressor zlibDecompressor = ZlibFactory.getZlibDecompressor(conf);

    checkSetDictionaryNullPointerException(zlibCompressor);
    checkSetDictionaryNullPointerException(zlibDecompressor);

    checkSetDictionaryArrayIndexOutOfBoundsException(zlibDecompressor);
    checkSetDictionaryArrayIndexOutOfBoundsException(zlibCompressor);
  } else {
    assertTrue("ZlibFactory is using native libs against request",
        ZlibFactory.isNativeZlibLoaded(conf));
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:TestZlibCompressorDecompressor.java

示例7: getDecompressor

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
public Decompressor getDecompressor() {
  CompressionCodec codec = getCodec(conf);
  if (codec != null) {
    Decompressor decompressor = CodecPool.getDecompressor(codec);
    if (LOG.isTraceEnabled()) LOG.trace("Retrieved decompressor " + decompressor
        + " from pool.");
    if (decompressor != null) {
      if (decompressor.finished()) {
        // Somebody returns the decompressor to CodecPool but is still using it.
        LOG.warn("Deompressor obtained from CodecPool is already finished()");
      }
      decompressor.reset();
    }
    return decompressor;
  }

  return null;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:Compression.java

示例8: decompress

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
/**
 * Decompresses data from the given stream using the configured compression algorithm. It will
 * throw an exception if the dest buffer does not have enough space to hold the decompressed data.
 * @param dest the output bytes buffer
 * @param destOffset start writing position of the output buffer
 * @param bufferedBoundedStream a stream to read compressed data from, bounded to the exact amount
 *          of compressed data
 * @param compressedSize compressed data size, header not included
 * @param uncompressedSize uncompressed data size, header not included
 * @param compressAlgo compression algorithm used
 * @throws IOException
 */
public static void decompress(byte[] dest, int destOffset, InputStream bufferedBoundedStream,
    int compressedSize, int uncompressedSize, Compression.Algorithm compressAlgo)
    throws IOException {

  if (dest.length - destOffset < uncompressedSize) {
    throw new IllegalArgumentException("Output buffer does not have enough space to hold "
        + uncompressedSize + " decompressed bytes, available: " + (dest.length - destOffset));
  }

  Decompressor decompressor = null;
  try {
    decompressor = compressAlgo.getDecompressor();
    InputStream is =
        compressAlgo.createDecompressionStream(bufferedBoundedStream, decompressor, 0);

    IOUtils.readFully(is, dest, destOffset, uncompressedSize);
    is.close();
  } finally {
    if (decompressor != null) {
      compressAlgo.returnDecompressor(decompressor);
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:36,代碼來源:Compression.java

示例9: createDecompressionStream

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
@Override
public synchronized InputStream createDecompressionStream(
    InputStream downStream, Decompressor decompressor,
    int downStreamBufferSize) throws IOException {
  if (!isSupported()) {
    throw new IOException(
        "LZO codec class not specified. Did you forget to set property "
            + CONF_LZO_CLASS + "?");
  }
  InputStream bis1 = null;
  if (downStreamBufferSize > 0) {
    bis1 = new BufferedInputStream(downStream, downStreamBufferSize);
  } else {
    bis1 = downStream;
  }
  conf.setInt("io.compression.codec.lzo.buffersize", 64 * 1024);
  CompressionInputStream cis =
      codec.createInputStream(bis1, decompressor);
  BufferedInputStream bis2 = new BufferedInputStream(cis, DATA_IBUF_SIZE);
  return bis2;
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:22,代碼來源:Compression.java

示例10: copy

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的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

示例11: openFile

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
private InputStream openFile(Path path) throws IOException {
        CompressionCodec codec=new CompressionCodecFactory(miniCluster.getConfig()).getCodec(path);
 	FSDataInputStream fileIn=dfsCluster.getFileSystem().open(path);
	// check if compressed
	if (codec==null) { // uncompressed
		return fileIn;
	} else { // compressed
		Decompressor decompressor = CodecPool.getDecompressor(codec);
		this.openDecompressors.add(decompressor); // to be returned later using close
		if (codec instanceof SplittableCompressionCodec) {
			long end = dfsCluster.getFileSystem().getFileStatus(path).getLen(); 
        		final SplitCompressionInputStream cIn =((SplittableCompressionCodec)codec).createInputStream(fileIn, decompressor, 0, end,SplittableCompressionCodec.READ_MODE.CONTINUOUS);
					return cIn;
      		} else {
        		return codec.createInputStream(fileIn,decompressor);
      		}
	}
}
 
開發者ID:ZuInnoTe,項目名稱:hadoopoffice,代碼行數:19,代碼來源:MapReduceExcelOutputIntegrationTest.java

示例12: openFile

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
public InputStream openFile(Path path) throws IOException {
        CompressionCodec codec=compressionCodecs.getCodec(path);
 	FSDataInputStream fileIn=fs.open(path);
	// check if compressed
	if (codec==null) { // uncompressed
	LOG.debug("Reading from an uncompressed file \""+path+"\"");
		return fileIn;
	} else { // compressed
		Decompressor decompressor = CodecPool.getDecompressor(codec);
		this.openDecompressors.add(decompressor); // to be returned later using close
		if (codec instanceof SplittableCompressionCodec) {
			LOG.debug("Reading from a compressed file \""+path+"\" with splittable compression codec");
			long end = fs.getFileStatus(path).getLen(); 
        		return ((SplittableCompressionCodec)codec).createInputStream(fileIn, decompressor, 0, end,SplittableCompressionCodec.READ_MODE.CONTINUOUS);
      		} else {
			LOG.debug("Reading from a compressed file \""+path+"\" with non-splittable compression codec");
        		return codec.createInputStream(fileIn,decompressor);
      		}
	}
}
 
開發者ID:ZuInnoTe,項目名稱:hadoopoffice,代碼行數:21,代碼來源:HadoopFileReader.java

示例13: openFile

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
private InputStream openFile(Path path) throws IOException {
        CompressionCodec codec=new CompressionCodecFactory(conf).getCodec(path);
 	FSDataInputStream fileIn=dfsCluster.getFileSystem().open(path);
	// check if compressed
	if (codec==null) { // uncompressed
		return fileIn;
	} else { // compressed
		Decompressor decompressor = CodecPool.getDecompressor(codec);
		this.openDecompressors.add(decompressor); // to be returned later using close
		if (codec instanceof SplittableCompressionCodec) {
			long end = dfsCluster.getFileSystem().getFileStatus(path).getLen(); 
        		final SplitCompressionInputStream cIn =((SplittableCompressionCodec)codec).createInputStream(fileIn, decompressor, 0, end,SplittableCompressionCodec.READ_MODE.CONTINUOUS);
					return cIn;
      		} else {
        		return codec.createInputStream(fileIn,decompressor);
      		}
	}
}
 
開發者ID:ZuInnoTe,項目名稱:hadoopcryptoledger,代碼行數:19,代碼來源:SparkBitcoinBlockCounterSparkMasterIntegrationTest.java

示例14: getBufferedReader

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
public static BufferedReader getBufferedReader(File file, MapredContext context)
        throws IOException {
    URI fileuri = file.toURI();
    Path path = new Path(fileuri);

    Configuration conf = context.getJobConf();
    CompressionCodecFactory ccf = new CompressionCodecFactory(conf);
    CompressionCodec codec = ccf.getCodec(path);

    if (codec == null) {
        return new BufferedReader(new FileReader(file));
    } else {
        Decompressor decompressor = CodecPool.getDecompressor(codec);
        FileInputStream fis = new FileInputStream(file);
        CompressionInputStream cis = codec.createInputStream(fis, decompressor);
        BufferedReader br = new BufferedReaderExt(new InputStreamReader(cis), decompressor);
        return br;
    }
}
 
開發者ID:apache,項目名稱:incubator-hivemall,代碼行數:20,代碼來源:HadoopUtils.java

示例15: getDecompressor

import org.apache.hadoop.io.compress.Decompressor; //導入依賴的package包/類
public Decompressor getDecompressor() {
  CompressionCodec codec = getCodec(conf);
  if (codec != null) {
    Decompressor decompressor = CodecPool.getDecompressor(codec);
    if (decompressor != null) {
      if (decompressor.finished()) {
        // Somebody returns the decompressor to CodecPool but is still using
        // it.
        LOG
            .warn("Deompressor obtained from CodecPool is already finished()");
        // throw new AssertionError(
        // "Decompressor obtained from CodecPool is already finished()");
      }
      decompressor.reset();
    }
    return decompressor;
  }

  return null;
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:21,代碼來源:Compression.java


注:本文中的org.apache.hadoop.io.compress.Decompressor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。