public void testCombineUnordered_empty() { try { Hashing.combineUnordered(Collections.<HashCode>emptySet()); fail(); } catch (IllegalArgumentException expected) { } }
public void testCombineUnordered_randomHashCodes() { Random random = new Random(RANDOM_SEED); List<HashCode> hashCodes = Lists.newArrayList(); for (int i = 0; i < 10; i++) { hashCodes.add(HashCode.fromLong(random.nextLong())); } HashCode hashCode1 = Hashing.combineUnordered(hashCodes); Collections.shuffle(hashCodes); HashCode hashCode2 = Hashing.combineUnordered(hashCodes); assertEquals(hashCode1, hashCode2); }
public void testCombineUnordered() { HashCode hash31 = HashCode.fromInt(31); HashCode hash32 = HashCode.fromInt(32); assertEquals(hash32, Hashing.combineUnordered(ImmutableList.of(hash32))); assertEquals(HashCode.fromInt(64), Hashing.combineUnordered(ImmutableList.of(hash32, hash32))); assertEquals( HashCode.fromInt(96), Hashing.combineUnordered(ImmutableList.of(hash32, hash32, hash32))); assertEquals( Hashing.combineUnordered(ImmutableList.of(hash31, hash32)), Hashing.combineUnordered(ImmutableList.of(hash32, hash31))); }
public void testCombineUnordered_differentBitLengths() { try { HashCode unused = Hashing.combineUnordered(ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L))); fail(); } catch (IllegalArgumentException expected) { } }
private String generateHash(@Nonnull List<TableRow> rows) { List<HashCode> rowHashes = Lists.newArrayList(); for (TableRow row : rows) { List<String> cellsInOneRow = Lists.newArrayList(); for (TableCell cell : row.getF()) { cellsInOneRow.add(Objects.toString(cell.getV())); Collections.sort(cellsInOneRow); } rowHashes.add(Hashing.sha1().hashString(cellsInOneRow.toString(), StandardCharsets.UTF_8)); } return Hashing.combineUnordered(rowHashes).toString(); }
public void testCombineUnordered_randomHashCodes() { Random random = new Random(RANDOM_SEED); List<HashCode> hashCodes = Lists.newArrayList(); for (int i = 0; i < 10; i++) { hashCodes.add(HashCode.fromLong(random.nextLong())); } HashCode hashCode1 = Hashing.combineUnordered(hashCodes); Collections.shuffle(hashCodes); HashCode hashCode2 = Hashing.combineUnordered(hashCodes); assertEquals(hashCode1, hashCode2); }
public void testCombineUnordered_empty() { try { Hashing.combineUnordered(Collections.<HashCode>emptySet()); fail(); } catch (IllegalArgumentException expected) { } }
return hashCodes.size() > 0 ? Hashing.combineUnordered(hashCodes).padToLong() : 0;
public void testCombineUnordered() { HashCode hash31 = HashCode.fromInt(31); HashCode hash32 = HashCode.fromInt(32); assertEquals(hash32, Hashing.combineUnordered(ImmutableList.of(hash32))); assertEquals(HashCode.fromInt(64), Hashing.combineUnordered(ImmutableList.of(hash32, hash32))); assertEquals(HashCode.fromInt(96), Hashing.combineUnordered(ImmutableList.of(hash32, hash32, hash32))); assertEquals( Hashing.combineUnordered(ImmutableList.of(hash31, hash32)), Hashing.combineUnordered(ImmutableList.of(hash32, hash31))); }
public void testCombineUnordered_differentBitLengths() { try { HashCode unused = Hashing.combineUnordered(ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L))); fail(); } catch (IllegalArgumentException expected) { } }
.putLong(checksum(entry.getValue(), hashFunc)).hash()); return hashCodes.size() > 0 ? Hashing.combineUnordered(hashCodes).padToLong() : hashFunc.newHasher().hash().padToLong(); hashCodes.add(hashFunc.newHasher().putLong(checksum(item, hashFunc)).hash()); return hashCodes.size() > 0 ? Hashing.combineUnordered(hashCodes).padToLong() : hashFunc.newHasher().hash().padToLong();