Package net.jpountz.lz4

Examples of net.jpountz.lz4.LZ4Decompressor.decompress()


      LZ4Decompressor decompressor = lz4Factory.decompressor();

      int size = ByteBuffer.wrap(in).getInt();

      out = new byte[size];
      decompressor.decompress(in, Ints.BYTES, out, 0, out.length);
    }
    return out == null ? null : out;
  }
}
View Full Code Here


    // decompress data
    // - method 1: when the decompressed length is known
    LZ4FastDecompressor decompressor = factory.fastDecompressor();
    byte[] restored = new byte[decompressedLength];
    int compressedLength2 = decompressor.decompress(compressed, 0, restored, 0, decompressedLength);
    // compressedLength == compressedLength2

    // - method 2: when the compressed length is known (a little slower)
    // the destination buffer needs to be over-sized
    LZ4SafeDecompressor decompressor2 = factory.safeDecompressor();
View Full Code Here

      int decompressedLength = compbb.getInt();

     
      LZ4FastDecompressor decompressor = factory.fastDecompressor();
      byte[] decompressedBytes = new byte[decompressedLength];
      int compressedLength2 = decompressor.decompress(bytes, 4, decompressedBytes, 0, decompressedLength);
     
      assert(compressedLength == compressedLength2);
     
      return codecUncompressed.createObjectFromBytes(decompressedBytes);
   }
View Full Code Here

      int compressedBytesOffset = buffer.arrayOffset() + buffer.position();
      byte[] compressedBytes    = buffer.array();
     
      LZ4FastDecompressor decompressor = factory.fastDecompressor();
      byte[] decompressedBytes = new byte[decompressedLength];
      int compressedLength2 = decompressor.decompress(compressedBytes, compressedBytesOffset, decompressedBytes, 0, decompressedLength);
     
      assert(compressedLength == compressedLength2);
     
      return codecUncompressed.createObjectFromBytes(decompressedBytes);
   }
View Full Code Here

    // compressedLength == compressedLength2

    // - method 2: when the compressed length is known (a little slower)
    // the destination buffer needs to be over-sized
    LZ4SafeDecompressor decompressor2 = factory.safeDecompressor();
    int decompressedLength2 = decompressor2.decompress(compressed, 0, compressedLength, restored, 0);
    // decompressedLength == decompressedLength2
  }

}
View Full Code Here

  public void testDecompressorCompressNullPointerException() {
    try {
      Lz4Decompressor decompressor = new Lz4Decompressor();
      byte[] bytes = generate(1024 * 6);
      decompressor.setInput(bytes, 0, bytes.length);
      decompressor.decompress(null, 0, 0);
      fail("testDecompressorCompressNullPointerException error !!!");
    } catch (NullPointerException ex) {
      // expected
    } catch (Exception e) {
      fail("testDecompressorCompressNullPointerException ex error !!!");
View Full Code Here

  public void testDecompressorCompressAIOBException() {
    try {
      Lz4Decompressor decompressor = new Lz4Decompressor();
      byte[] bytes = generate(1024 * 6);
      decompressor.setInput(bytes, 0, bytes.length);
      decompressor.decompress(new byte[] {}, 0, -1);
      fail("testDecompressorCompressAIOBException error !!!");
    } catch (ArrayIndexOutOfBoundsException ex) {
      // expected
    } catch (Exception e) {
      fail("testDecompressorCompressAIOBException ex error !!!");
View Full Code Here

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

TOP
Copyright © 2018 www.massapi.com. 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.