X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.lz4%2Fsrc%2Fnet%2Fjpountz%2Fxxhash%2Fpackage.html;fp=bundles%2Forg.simantics.lz4%2Fsrc%2Fnet%2Fjpountz%2Fxxhash%2Fpackage.html;h=f595d25a8ff37a98450a143f14d2b5f07343824a;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.lz4/src/net/jpountz/xxhash/package.html b/bundles/org.simantics.lz4/src/net/jpountz/xxhash/package.html new file mode 100644 index 000000000..f595d25a8 --- /dev/null +++ b/bundles/org.simantics.lz4/src/net/jpountz/xxhash/package.html @@ -0,0 +1,65 @@ + + + +
+ + + +xxhash hashing. This package supports both block hashing via +{@link net.jpountz.xxhash.XXHash32} and streaming hashing via +{@link net.jpountz.xxhash.StreamingXXHash32}. Have a look at +{@link net.jpountz.xxhash.XXHashFactory} to know how to get instances of these +interfaces.
+ +Streaming hashing is a little slower but doesn't require to load the whole +stream into memory.
+ +Sample block usage:
+ ++ XXHashFactory factory = XXHashFactory.fastestInstance(); + + byte[] data = "12345345234572".getBytes("UTF-8"); + + XXHash32 hash32 = factory.hash32(); + int seed = 0x9747b28c; // used to initialize the hash value, use whatever + // value you want, but always the same + int hash = hash32.hash(data, 0, data.length, seed); ++ +
Sample streaming usage:
+ ++ XXHashFactory factory = XXHashFactory.fastestInstance(); + + byte[] data = "12345345234572".getBytes("UTF-8"); + ByteArrayInputStream in = new ByteArrayInputStream(data); + + int seed = 0x9747b28c; // used to initialize the hash value, use whatever + // value you want, but always the same + StreamingXXHash32 hash32 = factory.newStreamingHash32(seed); + byte[] buf = new byte[8]; // for real-world usage, use a larger buffer, like 8192 bytes + for (;;) { + int read = in.read(buf); + if (read == -1) { + break; + } + hash32.update(buf, 0, read); + } + int hash = hash32.getValue(); ++ + +