public long hashInt(int input) { return hashInt(input, seed); }
public long hashLong(long input) { return hashLong(input, seed); }
public long hashUnsafeBytes(Object base, long offset, int length) { return hashUnsafeBytes(base, offset, length, seed); }
public static long hashUnsafeWords(Object base, long offset, int length, long seed) { assert (length % 8 == 0) : "lengthInBytes must be a multiple of 8 (word-aligned)"; long hash = hashBytesByWords(base, offset, length, seed); return fmix(hash); }
@Test public void randomizedStressTest() { int size = 65536; Random rand = new Random(); // A set used to track collision rate. Set<Long> hashcodes = new HashSet<>(); for (int i = 0; i < size; i++) { int vint = rand.nextInt(); long lint = rand.nextLong(); Assert.assertEquals(hasher.hashInt(vint), hasher.hashInt(vint)); Assert.assertEquals(hasher.hashLong(lint), hasher.hashLong(lint)); hashcodes.add(hasher.hashLong(lint)); } // A very loose bound. Assert.assertTrue(hashcodes.size() > size * 0.95d); }
public long hashUnsafeWords(Object base, long offset, int length) { return hashUnsafeWords(base, offset, length, seed); }
public static long hashInt(int input, long seed) { long hash = seed + PRIME64_5 + 4L; hash ^= (input & 0xFFFFFFFFL) * PRIME64_1; hash = Long.rotateLeft(hash, 23) * PRIME64_2 + PRIME64_3; return fmix(hash); }
@Test public void randomizedStressTest() { int size = 65536; Random rand = new Random(); // A set used to track collision rate. Set<Long> hashcodes = new HashSet<>(); for (int i = 0; i < size; i++) { int vint = rand.nextInt(); long lint = rand.nextLong(); Assert.assertEquals(hasher.hashInt(vint), hasher.hashInt(vint)); Assert.assertEquals(hasher.hashLong(lint), hasher.hashLong(lint)); hashcodes.add(hasher.hashLong(lint)); } // A very loose bound. Assert.assertTrue(hashcodes.size() > size * 0.95d); }
public long hashUnsafeWords(Object base, long offset, int length) { return hashUnsafeWords(base, offset, length, seed); }
public static long hashUnsafeWords(Object base, long offset, int length, long seed) { assert (length % 8 == 0) : "lengthInBytes must be a multiple of 8 (word-aligned)"; long hash = hashBytesByWords(base, offset, length, seed); return fmix(hash); }
public static long hashInt(int input, long seed) { long hash = seed + PRIME64_5 + 4L; hash ^= (input & 0xFFFFFFFFL) * PRIME64_1; hash = Long.rotateLeft(hash, 23) * PRIME64_2 + PRIME64_3; return fmix(hash); }
@Test public void randomizedStressTest() { int size = 65536; Random rand = new Random(); // A set used to track collision rate. Set<Long> hashcodes = new HashSet<>(); for (int i = 0; i < size; i++) { int vint = rand.nextInt(); long lint = rand.nextLong(); Assert.assertEquals(hasher.hashInt(vint), hasher.hashInt(vint)); Assert.assertEquals(hasher.hashLong(lint), hasher.hashLong(lint)); hashcodes.add(hasher.hashLong(lint)); } // A very loose bound. Assert.assertTrue(hashcodes.size() > size * 0.95d); }
public long hashUnsafeWords(Object base, long offset, int length) { return hashUnsafeWords(base, offset, length, seed); }
public long hashUnsafeBytes(Object base, long offset, int length) { return hashUnsafeBytes(base, offset, length, seed); }
public long hashInt(int input) { return hashInt(input, seed); }
public long hashLong(long input) { return hashLong(input, seed); }
public static long hashUnsafeWords(Object base, long offset, int length, long seed) { assert (length % 8 == 0) : "lengthInBytes must be a multiple of 8 (word-aligned)"; long hash = hashBytesByWords(base, offset, length, seed); return fmix(hash); }
public static long hashInt(int input, long seed) { long hash = seed + PRIME64_5 + 4L; hash ^= (input & 0xFFFFFFFFL) * PRIME64_1; hash = Long.rotateLeft(hash, 23) * PRIME64_2 + PRIME64_3; return fmix(hash); }
@Test public void randomizedStressTestBytes() { int size = 65536; Random rand = new Random(); // A set used to track collision rate. Set<Long> hashcodes = new HashSet<>(); for (int i = 0; i < size; i++) { int byteArrSize = rand.nextInt(100) * 8; byte[] bytes = new byte[byteArrSize]; rand.nextBytes(bytes); Assert.assertEquals( hasher.hashUnsafeWords(bytes, Platform.BYTE_ARRAY_OFFSET, byteArrSize), hasher.hashUnsafeWords(bytes, Platform.BYTE_ARRAY_OFFSET, byteArrSize)); hashcodes.add(hasher.hashUnsafeWords( bytes, Platform.BYTE_ARRAY_OFFSET, byteArrSize)); } // A very loose bound. Assert.assertTrue(hashcodes.size() > size * 0.95d); }
public long hashUnsafeBytes(Object base, long offset, int length) { return hashUnsafeBytes(base, offset, length, seed); }