Package org.apache.hadoop.io.compress

Examples of org.apache.hadoop.io.compress.Compressor


    // within the estimated buffer size, then the cost is not worth it.  If we are often well
    // outside the guesstimated buffer size, the processing can be done in half the time if we
    // go w/ the estimated size rather than let the buffer resize.
    ByteBufferOutputStream baos = new ByteBufferOutputStream(bufferSize);
    OutputStream os = baos;
    Compressor poolCompressor = null;
    try {
      if (compressor != null) {
        if (compressor instanceof Configurable) ((Configurable)compressor).setConf(this.conf);
        poolCompressor = CodecPool.getCompressor(compressor);
        os = compressor.createOutputStream(os, poolCompressor);
View Full Code Here


    Configuration conf = new Configuration();
    CompressionCodec codec = ReflectionUtils.newInstance(
      LzoCodec.class, conf);

    // Put a codec in the pool
    Compressor c1 = CodecPool.getCompressor(codec);
    assertEquals(LzoCompressor.CompressionStrategy.LZO1X_1,
                 ((LzoCompressor)c1).getStrategy());
    CodecPool.returnCompressor(c1);

    // Set compression strategy
    LzoCodec.setCompressionStrategy(conf, LzoCompressor.CompressionStrategy.LZO1C_BEST_COMPRESSION);

    Compressor c2 = CodecPool.getCompressor(codec, conf);
    assertSame(c1, c2);

    assertEquals(LzoCompressor.CompressionStrategy.LZO1C_BEST_COMPRESSION,
                 ((LzoCompressor)c2).getStrategy());
View Full Code Here

    Configuration conf = new Configuration();
    CompressionCodec codec = ReflectionUtils.newInstance(
      LzoCodec.class, conf);

    // Put a codec in the pool
    Compressor c1 = CodecPool.getCompressor(codec);
    assertEquals(LzoCompressor.CompressionStrategy.LZO1X_1,
                 ((LzoCompressor)c1).getStrategy());
    CodecPool.returnCompressor(c1);

    // Set compression strategy
    int newBufSize = LzoCodec.DEFAULT_LZO_BUFFER_SIZE * 2;
    LzoCodec.setBufferSize(conf, newBufSize);

    Compressor c2 = CodecPool.getCompressor(codec, conf);
    assertSame(c1, c2);

    assertEquals(newBufSize, ((LzoCompressor)c2).getDirectBufferSize());

  }
View Full Code Here

    // Set compression strategy
    LzoCodec.setCompressionStrategy(conf, LzoCompressor.CompressionStrategy.LZO1C_BEST_COMPRESSION);

    // Put a codec in the pool with BEST_COMPRESSION strategy
    Compressor c1 = CodecPool.getCompressor(codec, conf);
    assertEquals(LzoCompressor.CompressionStrategy.LZO1C_BEST_COMPRESSION,
                 ((LzoCompressor)c1).getStrategy());
    CodecPool.returnCompressor(c1);

    // Get it back from the pool without specifying any configuration,
    // it should return to default compression
    Compressor c2 = CodecPool.getCompressor(codec);
    assertSame(c1, c2);

    assertEquals(LzoCompressor.CompressionStrategy.LZO1X_1,
                 ((LzoCompressor)c2).getStrategy());
  }
View Full Code Here

    return totalSize;
  }

  public byte[] createTestV1Block(Compression.Algorithm algo)
      throws IOException {
    Compressor compressor = algo.getCompressor();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OutputStream os = algo.createCompressionStream(baos, compressor, 0);
    DataOutputStream dos = new DataOutputStream(os);
    BlockType.META.write(dos); // Let's make this a meta block.
    writeTestBlockContents(dos);
View Full Code Here

      }
    }

    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);
View Full Code Here

    fs = (HFileSystem)HFileSystem.get(TEST_UTIL.getConfiguration());
  }

  public byte[] createTestV1Block(Compression.Algorithm algo)
      throws IOException {
    Compressor compressor = algo.getCompressor();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OutputStream os = algo.createCompressionStream(baos, compressor, 0);
    DataOutputStream dos = new DataOutputStream(os);
    BlockType.META.write(dos); // Let's make this a meta block.
    TestHFileBlock.writeTestBlockContents(dos);
View Full Code Here

    return totalSize;
  }

  public byte[] createTestV1Block(Compression.Algorithm algo)
      throws IOException {
    Compressor compressor = algo.getCompressor();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OutputStream os = algo.createCompressionStream(baos, compressor, 0);
    DataOutputStream dos = new DataOutputStream(os);
    BlockType.META.write(dos); // Let's make this a meta block.
    writeTestBlockContents(dos);
View Full Code Here

    final Path resultPath = new Path(tempDir, "result.text");

    System.out.println("testHadoop20JHParser sent its output to " + resultPath);

    Compressor compressor;

    FileSystem fs = resultPath.getFileSystem(conf);
    CompressionCodec codec =
        new CompressionCodecFactory(conf).getCodec(resultPath);
    OutputStream output;
View Full Code Here

    final Path resultPath = new Path(tempDir, "result.text");

    System.out.println("testHadoop20JHParser sent its output to " + resultPath);

    Compressor compressor;

    FileSystem fs = resultPath.getFileSystem(conf);
    CompressionCodec codec =
        new CompressionCodecFactory(conf).getCodec(resultPath);
    OutputStream output;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.compress.Compressor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.