@Test public void testKnownLongInputs() { Assert.assertEquals(0, HiveHasher.hashLong(0L)); Assert.assertEquals(41, HiveHasher.hashLong(-42L)); Assert.assertEquals(42, HiveHasher.hashLong(42L)); Assert.assertEquals(-2147483648, HiveHasher.hashLong(Long.MIN_VALUE)); Assert.assertEquals(-2147483648, HiveHasher.hashLong(Long.MAX_VALUE)); }
@Test public void testKnownLongInputs() { Assert.assertEquals(0, HiveHasher.hashLong(0L)); Assert.assertEquals(41, HiveHasher.hashLong(-42L)); Assert.assertEquals(42, HiveHasher.hashLong(42L)); Assert.assertEquals(-2147483648, HiveHasher.hashLong(Long.MIN_VALUE)); Assert.assertEquals(-2147483648, HiveHasher.hashLong(Long.MAX_VALUE)); }
@Test public void testKnownLongInputs() { Assert.assertEquals(0, HiveHasher.hashLong(0L)); Assert.assertEquals(41, HiveHasher.hashLong(-42L)); Assert.assertEquals(42, HiveHasher.hashLong(42L)); Assert.assertEquals(-2147483648, HiveHasher.hashLong(Long.MIN_VALUE)); Assert.assertEquals(-2147483648, HiveHasher.hashLong(Long.MAX_VALUE)); }
@Test public void randomizedStressTest() { int size = 65536; Random rand = new Random(); // A set used to track collision rate. Set<Integer> hashcodes = new HashSet<>(); for (int i = 0; i < size; i++) { int vint = rand.nextInt(); long lint = rand.nextLong(); Assert.assertEquals(HiveHasher.hashInt(vint), HiveHasher.hashInt(vint)); Assert.assertEquals(HiveHasher.hashLong(lint), HiveHasher.hashLong(lint)); hashcodes.add(HiveHasher.hashLong(lint)); } // A very loose bound. Assert.assertTrue(hashcodes.size() > size * 0.95); }
@Test public void randomizedStressTest() { int size = 65536; Random rand = new Random(); // A set used to track collision rate. Set<Integer> hashcodes = new HashSet<>(); for (int i = 0; i < size; i++) { int vint = rand.nextInt(); long lint = rand.nextLong(); Assert.assertEquals(HiveHasher.hashInt(vint), HiveHasher.hashInt(vint)); Assert.assertEquals(HiveHasher.hashLong(lint), HiveHasher.hashLong(lint)); hashcodes.add(HiveHasher.hashLong(lint)); } // A very loose bound. Assert.assertTrue(hashcodes.size() > size * 0.95); }
@Test public void randomizedStressTest() { int size = 65536; Random rand = new Random(); // A set used to track collision rate. Set<Integer> hashcodes = new HashSet<>(); for (int i = 0; i < size; i++) { int vint = rand.nextInt(); long lint = rand.nextLong(); Assert.assertEquals(HiveHasher.hashInt(vint), HiveHasher.hashInt(vint)); Assert.assertEquals(HiveHasher.hashLong(lint), HiveHasher.hashLong(lint)); hashcodes.add(HiveHasher.hashLong(lint)); } // A very loose bound. Assert.assertTrue(hashcodes.size() > size * 0.95); }