public void testGoodFastHash32() { HashTestUtils.check2BitAvalanche(Hashing.goodFastHash(32), 250, 0.20); HashTestUtils.checkAvalanche(Hashing.goodFastHash(32), 250, 0.17); HashTestUtils.checkNo2BitCharacteristics(Hashing.goodFastHash(32)); HashTestUtils.checkNoFunnels(Hashing.goodFastHash(32)); HashTestUtils.assertInvariants(Hashing.goodFastHash(32)); }
public void testGoodFastHash128() { HashTestUtils.check2BitAvalanche(Hashing.goodFastHash(128), 250, 0.20); HashTestUtils.checkAvalanche(Hashing.goodFastHash(128), 250, 0.17); HashTestUtils.checkNo2BitCharacteristics(Hashing.goodFastHash(128)); HashTestUtils.checkNoFunnels(Hashing.goodFastHash(128)); HashTestUtils.assertInvariants(Hashing.goodFastHash(128)); }
public void testGoodFastHash256() { HashTestUtils.check2BitAvalanche(Hashing.goodFastHash(256), 250, 0.20); HashTestUtils.checkAvalanche(Hashing.goodFastHash(256), 250, 0.17); HashTestUtils.checkNo2BitCharacteristics(Hashing.goodFastHash(256)); HashTestUtils.checkNoFunnels(Hashing.goodFastHash(256)); HashTestUtils.assertInvariants(Hashing.goodFastHash(256)); }
/** * Tests equality of {@link Hashing#goodFastHash} instances. This test must be separate from * {@link #testSeededHashFunctionEquals} because the parameter to {@code goodFastHash} is a size, * not a seed, and because that size is rounded up. Thus, {@code goodFastHash} instances with * different parameters can be equal. That fact is a problem for {@code * testSeededHashFunctionEquals}. */ public void testGoodFastHashEquals() throws Exception { HashFunction hashFunction1a = Hashing.goodFastHash(1); HashFunction hashFunction1b = Hashing.goodFastHash(32); HashFunction hashFunction2a = Hashing.goodFastHash(33); HashFunction hashFunction2b = Hashing.goodFastHash(128); HashFunction hashFunction3a = Hashing.goodFastHash(129); HashFunction hashFunction3b = Hashing.goodFastHash(256); HashFunction hashFunction4a = Hashing.goodFastHash(257); HashFunction hashFunction4b = Hashing.goodFastHash(384); new EqualsTester() .addEqualityGroup(hashFunction1a, hashFunction1b) .addEqualityGroup(hashFunction2a, hashFunction2b) .addEqualityGroup(hashFunction3a, hashFunction3b) .addEqualityGroup(hashFunction4a, hashFunction4b) .testEquals(); assertEquals(hashFunction1a.toString(), hashFunction1b.toString()); assertEquals(hashFunction2a.toString(), hashFunction2b.toString()); assertEquals(hashFunction3a.toString(), hashFunction3b.toString()); assertEquals(hashFunction4a.toString(), hashFunction4b.toString()); }
hf = Hashing.goodFastHash(128); break;
@AndroidIncompatible // slow TODO(cpovirk): Maybe just reduce iterations under Android. public void testGoodFastHash() { for (int i = 1; i < 200; i += 17) { HashFunction hasher = Hashing.goodFastHash(i); assertTrue(hasher.bits() >= i); HashTestUtils.assertInvariants(hasher); } }
+ " Size INT64," + ") PRIMARY KEY (Key)"); hasher = Hashing.goodFastHash(64); client = env.getTestHelper().getDatabaseClient(db);
+ ") PRIMARY KEY (Key)", "CREATE INDEX " + INDEX_NAME + " ON " + TABLE_NAME + "(Fingerprint)"); hasher = Hashing.goodFastHash(64); dbClient = env.getTestHelper().getDatabaseClient(db); client = env.getTestHelper().getBatchClient(db);
@Override public int hashCode() { HashFunction hf = Hashing.goodFastHash(32); Hasher h = hf.newHasher(); h.putInt(slots.size()); for (int i=0; i<slots.size(); i++) { h.putInt(slots.get(i).size()); for (int j=0; j<slots.size(); j++) { h.putBytes(slots.get(i).get(j).getLowerRange()); h.putBytes(slots.get(i).get(j).getUpperRange()); } } return h.hash().asInt(); }
@Override public int hashCode() { HashFunction hf = Hashing.goodFastHash(32); Hasher h = hf.newHasher(); h.putInt(slots.size()); for (int i=0; i<slots.size(); i++) { h.putInt(slots.get(i).size()); for (int j=0; j<slots.size(); j++) { h.putBytes(slots.get(i).get(j).getLowerRange()); h.putBytes(slots.get(i).get(j).getUpperRange()); } } return h.hash().asInt(); }
private static Hasher buildHasher() { HashFunction function = Hashing.goodFastHash(16); Hasher hasher = function.newHasher(); return hasher; }
public String reserveId(String id) { if (!ids.containsKey(id)) { ids.put(id, 0); } return goodFastHash(128).hashString(id, StandardCharsets.UTF_8).toString(); }
/** * @return * {@linkplain Hashing#goodFastHash(int) Hashing.goodFastHash(32).newHasher().putInt(size()).putInt(getElementType().hashCode()).hash().asInt();} */ @Override public int hashCode() { return Hashing.goodFastHash(32).newHasher().putInt(size()).putInt(getElementType().hashCode()).hash().asInt(); }
@Override public int hashCode() { return Hashing.goodFastHash(32) .newHasher() .putInt(size()) .putInt(getElementType().hashCode()) .hash() .asInt(); }
@Override public int hashCode() { return Hashing.goodFastHash(32).hashInt(size()).asInt(); }
/** * @return * {@linkplain Hashing#goodFastHash(int) Hashing.goodFastHash(32).newHasher().putInt(size()).putInt(getElementType().hashCode()).hash().asInt();} */ @Override public int hashCode() { return Hashing.goodFastHash(32).hashInt(size()).asInt(); }
public void testGoodFastHash128() { HashTestUtils.check2BitAvalanche(Hashing.goodFastHash(128), 250, 0.20); HashTestUtils.checkAvalanche(Hashing.goodFastHash(128), 250, 0.17); HashTestUtils.checkNo2BitCharacteristics(Hashing.goodFastHash(128)); HashTestUtils.checkNoFunnels(Hashing.goodFastHash(128)); HashTestUtils.assertInvariants(Hashing.goodFastHash(128)); }
@Override public int hashCode() { return Hashing.goodFastHash(32) .newHasher() .putInt(getSubtype().hashCode()) .putLong(size()) .hash() .asInt(); }
@Override public int hashCode() { return Hashing.goodFastHash(32) .newHasher() .putInt(getSubtype().hashCode()) .putLong(size()) .hash() .asInt(); }
@Override public int hashCode() { return Hashing.goodFastHash(32) .newHasher() .putInt(getSubtype().hashCode()) .putLong(size()) .hash() .asInt(); }