@Override public Hasher putUnencodedChars(CharSequence chars) { for (Hasher hasher : hashers) { hasher.putUnencodedChars(chars); } return this; }
@Override public Hasher putUnencodedChars(CharSequence chars) { for (Hasher hasher : hashers) { hasher.putUnencodedChars(chars); } return this; }
@Override public Hasher putUnencodedChars(CharSequence chars) { for (Hasher hasher : hashers) { hasher.putUnencodedChars(chars); } return this; }
@Override public HashCode hashUnencodedChars(CharSequence input) { int len = input.length(); return newHasher(len * 2).putUnencodedChars(input).hash(); }
@Override public HashCode hashUnencodedChars(CharSequence input) { int len = input.length(); return newHasher(len * 2).putUnencodedChars(input).hash(); }
@Override public HashCode hashUnencodedChars(CharSequence input) { int len = input.length(); return newHasher(len * 2).putUnencodedChars(input).hash(); }
public void testStringsConsistency() { for (String s : Arrays.asList("", "some", "test", "strings", "to", "try")) { assertEquals(HASH_FN.newHasher().putUnencodedChars(s).hash(), HASH_FN.hashUnencodedChars(s)); } }
.addEqualityGroup( hashFunction.hashUnencodedChars("abc"), hashFunction.newHasher().putUnencodedChars("abc").hash(), hashFunction.newHasher().putUnencodedChars("ab").putUnencodedChars("c").hash(), hashFunction.newHasher().putUnencodedChars("a").putUnencodedChars("bc").hash(), hashFunction .newHasher() .putUnencodedChars("a") .putUnencodedChars("b") .putUnencodedChars("c") .hash(), hashFunction.newHasher().putChar('a').putUnencodedChars("bc").hash(), hashFunction.newHasher().putUnencodedChars("ab").putChar('c').hash(), hashFunction.newHasher().putChar('a').putChar('b').putChar('c').hash()) .testEquals(); assertEquals( hashFunction.hashUnencodedChars(string), hashFunction.newHasher().putUnencodedChars(string).hash()); for (Charset charset : CHARSETS) { assertEquals(
/** * This verifies that putUnencodedChars(String) and hashUnencodedChars(String) are equivalent, * even for funny strings composed by (possibly unmatched, and mostly illegal) surrogate * characters. (But doesn't test that they do the right thing - just their consistency). */ private static void assertHashStringWithSurrogatesEquivalence( HashFunction hashFunction, Random random) { int size = random.nextInt(8) + 1; char[] chars = new char[size]; for (int i = 0; i < chars.length; i++) { chars[i] = random.nextBoolean() ? randomLowSurrogate(random) : randomHighSurrogate(random); } String string = new String(chars); assertEquals( hashFunction.hashUnencodedChars(string), hashFunction.newHasher().putUnencodedChars(string).hash()); }
private static void assertPutString(char[] chars) { Hasher h1 = new NonStreamingVersion().newHasher(); Hasher h2 = new NonStreamingVersion().newHasher(); String s = new String(chars); // this is the correct implementation of the spec for (int i = 0; i < s.length(); i++) { h1.putChar(s.charAt(i)); } h2.putUnencodedChars(s); assertEquals(h1.hash(), h2.hash()); }
final String value = dimSelector.lookupName(row.get(0)); if (NullHandling.replaceWithDefault() || value != null) { hasher.putUnencodedChars(nullToSpecial(value)); hasher.putChar(CARDINALITY_AGG_SEPARATOR); hasher.putUnencodedChars(values[i]);
@Override public Hasher putUnencodedChars(CharSequence chars) { for (Hasher hasher : hashers) { hasher.putUnencodedChars(chars); } return this; }
@Override public Hasher putUnencodedChars(CharSequence chars) { for (Hasher hasher : hashers) { hasher.putUnencodedChars(chars); } return this; }
@Override public Hasher putUnencodedChars(CharSequence chars) { for (Hasher hasher : hashers) { hasher.putUnencodedChars(chars); } return this; }
@Override public Hasher putUnencodedChars(CharSequence chars) { for (Hasher hasher : hashers) { hasher.putUnencodedChars(chars); } return this; }
@Override public HashCode hashUnencodedChars(CharSequence input) { int len = input.length(); return newHasher(len * 2).putUnencodedChars(input).hash(); }
@Override public void visitMultiANewArrayInsn(final String desc, final int dims) { hasher.putUnencodedChars(desc).putInt(dims); }
@Override public HashCode hashUnencodedChars(CharSequence input) { int len = input.length(); return newHasher(len * 2).putUnencodedChars(input).hash(); }
/** Computes a 16-bit checksum of the contents of the specific ByteBuffer and channel name. */ private static int computeChecksum(byte[] buf, int offset, int length, String channel) { Hasher hasher = Hashing.murmur3_32().newHasher(); hasher.putBytes(buf, offset, length); hasher.putUnencodedChars(channel); return hasher.hash().asInt() & 0xffff; }
@PrePersist @PreUpdate private void initHash() { if (hash == 0) { this.hash = getPersistentHashFunction() .newHasher() .putUnencodedChars(className) .putObject(options, StringMapFunnel.INSTANCE) .hash().asInt(); } }