List of usage examples for com.google.common.hash Hashing sipHash24
public static HashFunction sipHash24(long k0, long k1)
From source file:com.scurrilous.circe.guava.GuavaHashProvider.java
@Override protected Hash get(HashParameters params, EnumSet<HashSupport> required) { if (params instanceof SipHash24Parameters) { final SipHash24Parameters sipParams = (SipHash24Parameters) params; return new HasherLongHash(Hashing.sipHash24(sipParams.seedLow(), sipParams.seedHigh()), params.algorithm());//w w w .j a v a 2s.c o m } if (params instanceof MurmurHash3Parameters) { final MurmurHash3Parameters murmurParams = (MurmurHash3Parameters) params; final int seed = murmurParams.seed(); switch (murmurParams.variant()) { case X86_32: return new HasherIntHash(Hashing.murmur3_32(seed), params.algorithm()); case X64_128: return new HasherHash(Hashing.murmur3_128(seed), params.algorithm()); default: throw new UnsupportedOperationException(); } } throw new UnsupportedOperationException(); }
From source file:com.github.mgunlogson.cuckoofilter4j.SerializableSaltedHasher.java
private static HashFunction configureHash(Algorithm alg, long seedNSalt, long addlSipSeed) { switch (alg) { case xxHash64: return new xxHashFunction(seedNSalt); case Murmur3_128: return Hashing.murmur3_128((int) seedNSalt); case Murmur3_32: return Hashing.murmur3_32((int) seedNSalt); case sha256:/*from www . j a v a 2 s .com*/ return Hashing.sha1(); case sipHash24: return Hashing.sipHash24(seedNSalt, addlSipSeed); default: throw new IllegalArgumentException("Invalid Enum Hashing Algorithm???"); } }
From source file:diskCacheV111.srm.dcache.CanonicalizingByteArrayStore.java
/** * Returns a {@code Token} for a particular byte array. * * As long as the token is referenced, the byte array is not eligible * for garbage collection.//www . j a va 2s .com * * The byte array ID can be extracted from the token. * * @param bytes a byte array * @return A {@code Token} referencing the given byte array */ @Nonnull public Token toToken(byte[] bytes) { Token token = null; long k1 = 0x00; do { HashCode hash = Hashing.sipHash24(K0, k1++).hashBytes(bytes); long id = hash.asLong(); Lock lock = locks.get(id); lock.lock(); try { byte[] canonical = load(id); if (canonical == null) { save(id, bytes); token = makeToken(id); } else if (Arrays.equals(bytes, canonical)) { token = makeToken(id); } } finally { lock.unlock(); } } while (token == null); return token; }