Parent Directory
|
Revision Log
|
Patch
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/JenkinsHash.java 2008/02/04 18:14:02 618357
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/JenkinsHash.java 2008/03/21 19:46:34 639775
@@ -20,6 +20,9 @@
package org.apache.hadoop.hbase.util;
+import java.io.FileInputStream;
+import java.io.IOException;
+
/**
* lookup3.c, by Bob Jenkins, May 2006, Public Domain.
* <a href="http://burtleburtle.net/bob/c/lookup3.c">lookup3.c</a>
@@ -231,4 +234,23 @@
return Long.valueOf(c & INT_MASK).intValue();
}
+
+ /**
+ * Compute the hash of the specified file
+ * @param args name of file to compute hash of.
+ * @throws IOException
+ */
+ public static void main(String[] args) throws IOException {
+ if (args.length != 1) {
+ System.err.println("Usage: JenkinsHash filename");
+ System.exit(-1);
+ }
+ FileInputStream in = new FileInputStream(args[0]);
+ byte[] bytes = new byte[512];
+ int value = 0;
+ for (int length = in.read(bytes); length > 0 ; length = in.read(bytes)) {
+ value = hash(bytes, length, value);
+ }
+ System.out.println(Math.abs(value));
+ }
}
| apache@apache.org | ViewVC Help |
| Powered by ViewVC 1.1.2 |