Example usage for com.google.common.hash Hashing murmur3_32

List of usage examples for com.google.common.hash Hashing murmur3_32

Introduction

In this page you can find the example usage for com.google.common.hash Hashing murmur3_32.

Prototype

public static HashFunction murmur3_32(int seed) 

Source Link

Document

Returns a hash function implementing the <a href="http://smhasher.googlecode.com/svn/trunk/MurmurHash3.cpp"> 32-bit murmur3 algorithm, x86 variant</a> (little-endian variant), using the given seed value.

Usage

From source file:com.picdrop.security.token.AuthTokenClaimSetFactory.java

@Inject
public AuthTokenClaimSetFactory(Repository<String, RegisteredUser> repo, Repository<String, TokenSet> tsrepo,
        @Named("service.jwt.auth.exp") int jwtExpiry, @Named("service.jwt.iss") String jwtIssuer,
        @Named("service.jwt.aud") String jwtAudience) {
    super(jwtExpiry, jwtIssuer, jwtAudience);

    this.repo = repo;
    this.tsrepo = tsrepo;
    this.hashf = Hashing.murmur3_32(new Random().nextInt());
}

From source file:com.picdrop.security.token.RefreshTokenClaimSetFactory.java

@Inject
public RefreshTokenClaimSetFactory(Repository<String, RegisteredUser> repo, Repository<String, TokenSet> tsrepo,
        @Named("service.jwt.refresh.exp") int jwtExpiry, @Named("service.jwt.iss") String jwtIssuer,
        @Named("service.jwt.aud") String jwtAudience) {
    super(jwtExpiry, jwtIssuer, jwtAudience);

    this.repo = repo;
    this.tsrepo = tsrepo;
    this.hashf = Hashing.murmur3_32(new Random().nextInt());
}

From source file:org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl.java

/**
 * compute pseudorandom key unique for given seed and {@link #auxiliaryId}
 * @param seed random int but fixed per session
 *//* w ww.  ja va 2 s .com*/
public void init(int seed) {
    if (auxiliaryId <= 0) {
        throw new IllegalStateException("auxiliaryId must be greater than 0");
    }

    HashFunction mm32Hf = Hashing.murmur3_32(seed);
    Hasher hasher = mm32Hf.newHasher(8);
    hasher.putInt(auxiliaryId);
    long hash = 0xFFFFFFFFL & hasher.hash().asInt();
    cookie = (auxiliaryId << 24) | (hash >> 8);
}

From source file:io.seldon.vw.VwFeatureHash.java

public Integer getFeatureHash(int label, String namespace, String feature) {
    int nsHash = 0;
    if (!StringUtils.isEmpty(namespace)) {
        HashFunction h = Hashing.murmur3_32(0);
        nsHash = h.hashBytes(namespace.getBytes()).asInt();
    }//from  w  w  w. ja  va  2s.c  om
    int hcl = 0;
    if (isInteger(feature))
        hcl = Integer.parseInt(feature) + nsHash;
    else {
        HashFunction h = Hashing.murmur3_32(nsHash);
        hcl = (h.hashBytes(feature.getBytes()).asInt());
    }
    int f = ((hcl * stride) + label - 1) & mask;
    return f;
}

From source file:edu.umd.marbl.mhap.sketch.HashUtils.java

public final static int[] computeHashesIntDouble(double obj, int numWords, int seed) {
    int[] hashes = new int[numWords];

    HashFunction hf = Hashing.murmur3_32(seed);

    for (int iter = 0; iter < numWords; iter++) {
        HashCode hc = hf.newHasher().putDouble(obj).putInt(iter).hash();

        hashes[iter] = hc.asInt();//  w ww.  j  a  v  a 2s  .com
    }

    return hashes;
}

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   w  w  w .j  a  v  a2 s.  c  o  m*/
        return Hashing.sha1();
    case sipHash24:
        return Hashing.sipHash24(seedNSalt, addlSipSeed);
    default:
        throw new IllegalArgumentException("Invalid Enum Hashing Algorithm???");
    }
}

From source file:mx.itam.metodos.minhashing.MinhashMapper.java

@Override
protected void setup(Context context) throws IOException, InterruptedException {
    this.functionsCount = 100;
    this.rows = context.getConfiguration().getInt(HadoopMinhashing.ROWS, 10);
    this.hashValues = new int[functionsCount];
    this.functions = new HashFunction[functionsCount];
    Random r = new Random(11);
    for (int i = 0; i < functionsCount; i++) {
        functions[i] = Hashing.murmur3_32(r.nextInt());
    }//  ww w  .j  a  va 2s .c om
    this.lsh = Hashing.murmur3_32(r.nextInt());
}

From source file:mx.itam.metodos.lshclustering.MinhashEmitMapper.java

@Override
public void setup(Context context) {
    int bands = context.getConfiguration().getInt(HadoopLSHClustering.BANDS, 10);
    this.rows = context.getConfiguration().getInt(HadoopLSHClustering.ROWS, 10);
    this.functionsCount = bands * rows;
    this.hashValues = new int[functionsCount];
    this.functions = new HashFunction[functionsCount];
    Random r = new Random(11);
    for (int i = 0; i < functionsCount; i++) {
        functions[i] = Hashing.murmur3_32(r.nextInt());
    }/*from www .  j  a v a 2s .  c  o m*/
    this.lsh = Hashing.murmur3_32(r.nextInt());
}

From source file:edu.umd.marbl.mhap.sketch.HashUtils.java

public final static int[] computeHashesIntFloat(float obj, int numWords, int seed) {
    int[] hashes = new int[numWords];

    HashFunction hf = Hashing.murmur3_32(seed);

    for (int iter = 0; iter < numWords; iter++) {
        HashCode hc = hf.newHasher().putFloat(obj).putInt(iter).hash();

        hashes[iter] = hc.asInt();/*  www.ja  v  a  2  s . c o m*/
    }

    return hashes;
}

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());/*from  ww  w. j  av  a2s . 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();
}