/** * Get a singleton instance of hash function of a given type. * @param type predefined hash type * @return hash function instance, or null if type is invalid */ public static Hash getInstance(int type) { switch(type) { case JENKINS_HASH: return JenkinsHash.getInstance(); case MURMUR_HASH: return MurmurHash.getInstance(); default: return null; } }
/** * 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); } try (FileInputStream in = new FileInputStream(args[0])) { byte[] bytes = new byte[512]; int value = 0; JenkinsHash hash = new JenkinsHash(); for (int length = in.read(bytes); length > 0; length = in.read(bytes)) { value = hash.hash(bytes, length, value); } System.out.println(Math.abs(value)); } } }
a = (a - c) & INT_MASK; a ^= rot(c, 4); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a, 6); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 8); b = (b + a) & INT_MASK; a = (a - c) & INT_MASK; a ^= rot(c,16); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a,19); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 4); b = (b + a) & INT_MASK; c ^= b; c = (c - rot(b,14)) & INT_MASK; a ^= c; a = (a - rot(c,11)) & INT_MASK; b ^= a; b = (b - rot(a,25)) & INT_MASK; c ^= b; c = (c - rot(b,16)) & INT_MASK; a ^= c; a = (a - rot(c,4)) & INT_MASK; b ^= a; b = (b - rot(a,14)) & INT_MASK; c ^= b; c = (c - rot(b,24)) & INT_MASK;
/** * 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; JenkinsHash hash = new JenkinsHash(); for (int length = in.read(bytes); length > 0 ; length = in.read(bytes)) { value = hash.hash(bytes, length, value); } System.out.println(Math.abs(value)); } }
/** * Get a singleton instance of hash function of a given type. * @param type predefined hash type * @return hash function instance, or null if type is invalid */ public static Hash getInstance(int type) { switch(type) { case JENKINS_HASH: return JenkinsHash.getInstance(); case MURMUR_HASH: return MurmurHash.getInstance(); default: return null; } }
a = (a - c) & INT_MASK; a ^= rot(c, 4); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a, 6); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 8); b = (b + a) & INT_MASK; a = (a - c) & INT_MASK; a ^= rot(c,16); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a,19); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 4); b = (b + a) & INT_MASK; c ^= b; c = (c - rot(b,14)) & INT_MASK; a ^= c; a = (a - rot(c,11)) & INT_MASK; b ^= a; b = (b - rot(a,25)) & INT_MASK; c ^= b; c = (c - rot(b,16)) & INT_MASK; a ^= c; a = (a - rot(c,4)) & INT_MASK; b ^= a; b = (b - rot(a,14)) & INT_MASK; c ^= b; c = (c - rot(b,24)) & INT_MASK;
/** * 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; JenkinsHash hash = new JenkinsHash(); for (int length = in.read(bytes); length > 0 ; length = in.read(bytes)) { value = hash.hash(bytes, length, value); } System.out.println(Math.abs(value)); } }
/** * Get a singleton instance of hash function of a given type. * @param type predefined hash type * @return hash function instance, or null if type is invalid */ public static Hash getInstance(int type) { switch(type) { case JENKINS_HASH: return JenkinsHash.getInstance(); case MURMUR_HASH: return MurmurHash.getInstance(); default: return null; } }
a = (a - c) & INT_MASK; a ^= rot(c, 4); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a, 6); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 8); b = (b + a) & INT_MASK; a = (a - c) & INT_MASK; a ^= rot(c,16); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a,19); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 4); b = (b + a) & INT_MASK; c ^= b; c = (c - rot(b,14)) & INT_MASK; a ^= c; a = (a - rot(c,11)) & INT_MASK; b ^= a; b = (b - rot(a,25)) & INT_MASK; c ^= b; c = (c - rot(b,16)) & INT_MASK; a ^= c; a = (a - rot(c,4)) & INT_MASK; b ^= a; b = (b - rot(a,14)) & INT_MASK; c ^= b; c = (c - rot(b,24)) & INT_MASK;
/** * 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; JenkinsHash hash = new JenkinsHash(); for (int length = in.read(bytes); length > 0 ; length = in.read(bytes)) { value = hash.hash(bytes, length, value); } System.out.println(Math.abs(value)); } }
/** * Get a singleton instance of hash function of a given type. * @param type predefined hash type * @return hash function instance, or null if type is invalid */ public static Hash getInstance(int type) { switch(type) { case JENKINS_HASH: return JenkinsHash.getInstance(); case MURMUR_HASH: return MurmurHash.getInstance(); default: return null; } }
a = (a - c) & INT_MASK; a ^= rot(c, 4); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a, 6); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 8); b = (b + a) & INT_MASK; a = (a - c) & INT_MASK; a ^= rot(c,16); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a,19); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 4); b = (b + a) & INT_MASK; c ^= b; c = (c - rot(b,14)) & INT_MASK; a ^= c; a = (a - rot(c,11)) & INT_MASK; b ^= a; b = (b - rot(a,25)) & INT_MASK; c ^= b; c = (c - rot(b,16)) & INT_MASK; a ^= c; a = (a - rot(c,4)) & INT_MASK; b ^= a; b = (b - rot(a,14)) & INT_MASK; c ^= b; c = (c - rot(b,24)) & INT_MASK;
/** * 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; JenkinsHash hash = new JenkinsHash(); for (int length = in.read(bytes); length > 0 ; length = in.read(bytes)) { value = hash.hash(bytes, length, value); } System.out.println(Math.abs(value)); } }
/** * Get a singleton instance of hash function of a given type. * @param type predefined hash type * @return hash function instance, or null if type is invalid */ public static Hash getInstance(int type) { switch(type) { case JENKINS_HASH: return JenkinsHash.getInstance(); case MURMUR_HASH: return MurmurHash.getInstance(); default: return null; } }
a = (a - c) & INT_MASK; a ^= rot(c, 4); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a, 6); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 8); b = (b + a) & INT_MASK; a = (a - c) & INT_MASK; a ^= rot(c,16); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a,19); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 4); b = (b + a) & INT_MASK; c ^= b; c = (c - rot(b,14)) & INT_MASK; a ^= c; a = (a - rot(c,11)) & INT_MASK; b ^= a; b = (b - rot(a,25)) & INT_MASK; c ^= b; c = (c - rot(b,16)) & INT_MASK; a ^= c; a = (a - rot(c,4)) & INT_MASK; b ^= a; b = (b - rot(a,14)) & INT_MASK; c ^= b; c = (c - rot(b,24)) & INT_MASK;
/** * 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); } try (FileInputStream in = new FileInputStream(args[0])) { byte[] bytes = new byte[512]; int value = 0; JenkinsHash hash = new JenkinsHash(); for (int length = in.read(bytes); length > 0; length = in.read(bytes)) { value = hash.hash(bytes, length, value); } System.out.println(Math.abs(value)); } } }
/** * Get a singleton instance of hash function of a given type. * @param type predefined hash type * @return hash function instance, or null if type is invalid */ public static Hash getInstance(int type) { switch(type) { case JENKINS_HASH: return JenkinsHash.getInstance(); case MURMUR_HASH: return MurmurHash.getInstance(); default: return null; } }
a = (a - c) & INT_MASK; a ^= rot(c, 4); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a, 6); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 8); b = (b + a) & INT_MASK; a = (a - c) & INT_MASK; a ^= rot(c,16); c = (c + b) & INT_MASK; b = (b - a) & INT_MASK; b ^= rot(a,19); a = (a + c) & INT_MASK; c = (c - b) & INT_MASK; c ^= rot(b, 4); b = (b + a) & INT_MASK; c ^= b; c = (c - rot(b,14)) & INT_MASK; a ^= c; a = (a - rot(c,11)) & INT_MASK; b ^= a; b = (b - rot(a,25)) & INT_MASK; c ^= b; c = (c - rot(b,16)) & INT_MASK; a ^= c; a = (a - rot(c,4)) & INT_MASK; b ^= a; b = (b - rot(a,14)) & INT_MASK; c ^= b; c = (c - rot(b,24)) & INT_MASK;
cfg.set("hadoop.util.hash.type", "jenkins"); assertTrue("testHash jenkins configuration error !!!", JenkinsHash.getInstance() == Hash.getInstance(cfg)); JenkinsHash.getInstance() == Hash.getInstance(Hash.JENKINS_HASH)); assertTrue("testHash error murmur getInstance !!!", MurmurHash.getInstance() == Hash.getInstance(Hash.MURMUR_HASH));
cfg.set("hadoop.util.hash.type", "jenkins"); assertTrue("testHash jenkins configuration error !!!", JenkinsHash.getInstance() == Hash.getInstance(cfg)); JenkinsHash.getInstance() == Hash.getInstance(Hash.JENKINS_HASH)); assertTrue("testHash error murmur getInstance !!!", MurmurHash.getInstance() == Hash.getInstance(Hash.MURMUR_HASH));