| 20 |
|
|
| 21 |
package org.apache.hadoop.hbase.util; |
package org.apache.hadoop.hbase.util; |
| 22 |
|
|
| 23 |
|
import java.io.FileInputStream; |
| 24 |
|
import java.io.IOException; |
| 25 |
|
|
| 26 |
/** |
/** |
| 27 |
* lookup3.c, by Bob Jenkins, May 2006, Public Domain. |
* lookup3.c, by Bob Jenkins, May 2006, Public Domain. |
| 28 |
* <a href="http://burtleburtle.net/bob/c/lookup3.c">lookup3.c</a> |
* <a href="http://burtleburtle.net/bob/c/lookup3.c">lookup3.c</a> |
| 234 |
|
|
| 235 |
return Long.valueOf(c & INT_MASK).intValue(); |
return Long.valueOf(c & INT_MASK).intValue(); |
| 236 |
} |
} |
| 237 |
|
|
| 238 |
|
/** |
| 239 |
|
* Compute the hash of the specified file |
| 240 |
|
* @param args name of file to compute hash of. |
| 241 |
|
* @throws IOException |
| 242 |
|
*/ |
| 243 |
|
public static void main(String[] args) throws IOException { |
| 244 |
|
if (args.length != 1) { |
| 245 |
|
System.err.println("Usage: JenkinsHash filename"); |
| 246 |
|
System.exit(-1); |
| 247 |
|
} |
| 248 |
|
FileInputStream in = new FileInputStream(args[0]); |
| 249 |
|
byte[] bytes = new byte[512]; |
| 250 |
|
int value = 0; |
| 251 |
|
for (int length = in.read(bytes); length > 0 ; length = in.read(bytes)) { |
| 252 |
|
value = hash(bytes, length, value); |
| 253 |
|
} |
| 254 |
|
System.out.println(Math.abs(value)); |
| 255 |
|
} |
| 256 |
} |
} |