MurmurHash { public static long hash64A(byte[] data, int seed) { return hash64A(ByteBuffer.wrap(data), seed); } private  MurmurHash(); static int hash(byte[] data, int seed); static int hash(byte[] data, int offset, int length, int seed); static int hash(ByteBuffer buf, int seed); static long hash64A(byte[] data, int seed); static long hash64A(byte[] data, int offset, int length, int seed); static long hash64A(ByteBuffer buf, int seed);  }
@Test public void testForLotsOfChange64() throws UnsupportedEncodingException { long h1 = MurmurHash.hash64A("abc".getBytes(Charsets.UTF_8), 0); long h2 = MurmurHash.hash64A("abc ".getBytes(Charsets.UTF_8), 0); int flipCount = Long.bitCount(h1 ^ h2); Assert.assertTrue("Small changes should result in lots of bit flips, only found " + flipCount, flipCount > 25); }
@Test public void testHash64() { Assert.assertEquals(0x9cc9c33498a95efbL, MurmurHash.hash64A("abc".getBytes(Charsets.UTF_8), 0)); Assert.assertEquals(0xd2c8c9b470122bddL, MurmurHash.hash64A("abc def ghi jkl ".getBytes(Charsets.UTF_8), 0)); Assert.assertEquals(0xcd37895736a81cbcL, MurmurHash.hash64A("abc def ghi jkl moreGoo".getBytes(Charsets.UTF_8), 0)); }