X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.lz4%2Fsrc%2Fnet%2Fjpountz%2Flz4%2Fpackage.html;fp=bundles%2Forg.simantics.lz4%2Fsrc%2Fnet%2Fjpountz%2Flz4%2Fpackage.html;h=e5341067436c147572ac0acc6b1707a7ce03674b;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.lz4/src/net/jpountz/lz4/package.html b/bundles/org.simantics.lz4/src/net/jpountz/lz4/package.html new file mode 100644 index 000000000..e53410674 --- /dev/null +++ b/bundles/org.simantics.lz4/src/net/jpountz/lz4/package.html @@ -0,0 +1,55 @@ + + + +
+ + + +LZ4 compression. The entry point of the API is the +{@link net.jpountz.lz4.LZ4Factory} class, which gives access to +{@link net.jpountz.lz4.LZ4Compressor compressors} and +{@link net.jpountz.lz4.LZ4SafeDecompressor decompressors}.
+ + +Sample usage:
+ ++ LZ4Factory factory = LZ4Factory.fastestInstance(); + + byte[] data = "12345345234572".getBytes("UTF-8"); + final int decompressedLength = data.length; + + // compress data + LZ4Compressor compressor = factory.fastCompressor(); + int maxCompressedLength = compressor.maxCompressedLength(decompressedLength); + byte[] compressed = new byte[maxCompressedLength]; + int compressedLength = compressor.compress(data, 0, decompressedLength, compressed, 0, maxCompressedLength); + + // 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(); + int decompressedLength2 = decompressor2.decompress(compressed, 0, compressedLength, restored, 0); + // decompressedLength == decompressedLength2 ++ + +