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


Java Lz4Compressor.compress方法代码示例

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


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

示例1: testSetInputWithBytesSizeMoreThenDefaultLz4CompressorByfferSize

import org.apache.hadoop.io.compress.lz4.Lz4Compressor; //导入方法依赖的package包/类
@Test
public void testSetInputWithBytesSizeMoreThenDefaultLz4CompressorByfferSize() {
  int BYTES_SIZE = 1024 * 64 + 1;
  try {
    Lz4Compressor compressor = new Lz4Compressor();
    byte[] bytes = generate(BYTES_SIZE);
    assertTrue("needsInput error !!!", compressor.needsInput());
    compressor.setInput(bytes, 0, bytes.length);
    byte[] emptyBytes = new byte[BYTES_SIZE];
    int csize = compressor.compress(emptyBytes, 0, bytes.length);
    assertTrue(
        "testSetInputWithBytesSizeMoreThenDefaultLz4CompressorByfferSize error !!!",
        csize != 0);
  } catch (Exception ex) {
    fail("testSetInputWithBytesSizeMoreThenDefaultLz4CompressorByfferSize ex error !!!");
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:TestLz4CompressorDecompressor.java

示例2: testCompressorCompressNullPointerException

import org.apache.hadoop.io.compress.lz4.Lz4Compressor; //导入方法依赖的package包/类
@Test
public void testCompressorCompressNullPointerException() {
  try {
    Lz4Compressor compressor = new Lz4Compressor();
    byte[] bytes = generate(1024 * 6);
    compressor.setInput(bytes, 0, bytes.length);
    compressor.compress(null, 0, 0);
    fail("testCompressorCompressNullPointerException error !!!");
  } catch (NullPointerException ex) {
    // expected
  } catch (Exception e) {
    fail("testCompressorCompressNullPointerException ex error !!!");
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:TestLz4CompressorDecompressor.java

示例3: testCompressorCompressAIOBException

import org.apache.hadoop.io.compress.lz4.Lz4Compressor; //导入方法依赖的package包/类
@Test
public void testCompressorCompressAIOBException() {
  try {
    Lz4Compressor compressor = new Lz4Compressor();
    byte[] bytes = generate(1024 * 6);
    compressor.setInput(bytes, 0, bytes.length);
    compressor.compress(new byte[] {}, 0, -1);
    fail("testCompressorCompressAIOBException error !!!");
  } catch (ArrayIndexOutOfBoundsException ex) {
    // expected
  } catch (Exception e) {
    fail("testCompressorCompressAIOBException ex error !!!");
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:TestLz4CompressorDecompressor.java

示例4: testCompressDecompress

import org.apache.hadoop.io.compress.lz4.Lz4Compressor; //导入方法依赖的package包/类
@Test
public void testCompressDecompress() {
  int BYTE_SIZE = 1024 * 54;
  byte[] bytes = generate(BYTE_SIZE);
  Lz4Compressor compressor = new Lz4Compressor();
  try {
    compressor.setInput(bytes, 0, bytes.length);
    assertTrue("Lz4CompressDecompress getBytesRead error !!!",
        compressor.getBytesRead() > 0);
    assertTrue(
        "Lz4CompressDecompress getBytesWritten before compress error !!!",
        compressor.getBytesWritten() == 0);

    byte[] compressed = new byte[BYTE_SIZE];
    int cSize = compressor.compress(compressed, 0, compressed.length);
    assertTrue(
        "Lz4CompressDecompress getBytesWritten after compress error !!!",
        compressor.getBytesWritten() > 0);
    Lz4Decompressor decompressor = new Lz4Decompressor();
    // set as input for decompressor only compressed data indicated with cSize
    decompressor.setInput(compressed, 0, cSize);
    byte[] decompressed = new byte[BYTE_SIZE];
    decompressor.decompress(decompressed, 0, decompressed.length);

    assertTrue("testLz4CompressDecompress finished error !!!", decompressor.finished());      
    assertArrayEquals(bytes, decompressed);
    compressor.reset();
    decompressor.reset();
    assertTrue("decompressor getRemaining error !!!",decompressor.getRemaining() == 0);
  } catch (Exception e) {
    fail("testLz4CompressDecompress ex error!!!");
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:34,代码来源:TestLz4CompressorDecompressor.java


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