]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.lz4/src/net/jpountz/xxhash/package.html
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.lz4 / src / net / jpountz / xxhash / package.html
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 (file)
index 0000000..f595d25
--- /dev/null
@@ -0,0 +1,65 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<!--
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+<body>
+<p>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.</p>
+
+<p>Streaming hashing is a little slower but doesn't require to load the whole
+stream into memory.</p>
+
+<p>Sample block usage:</p>
+
+<pre class="prettyprint">
+    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);
+</pre>
+
+<p>Sample streaming usage:</p>
+
+<pre class="prettyprint">
+    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();
+</pre>
+
+</body>
+</html>