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:org.springside.modules.security.utils.Digests.java

/**
 * murmur32seed//from w w w  .  j a  va  2  s.  co m
 */
public static int murmur32(String input, int seed) {
    return Hashing.murmur3_32(seed).hashString(input, Charsets.UTF_8).asInt();
}

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

public static double[] randomStringGuassianVector(String str, int n, int seed) {
    int[] seeds = new int[4];
    for (int iter = 0; iter < 4; iter++) {
        HashFunction hf = Hashing.murmur3_32(seed * 4 + iter);
        HashCode hc = hf.newHasher().putUnencodedChars(str).hash();

        seeds[iter] = hc.asInt();/*from  w w  w . j  a  v  a2  s  .co m*/
    }

    //now generate the guassian
    MersenneTwisterFast rand = new MersenneTwisterFast(seeds);

    double[] vec = new double[n];
    for (int iter = 0; iter < n; iter++) {
        vec[iter] = rand.nextGaussian();
    }

    //normalize
    double norm = BasicMath.norm(vec);
    if (norm < 1.0e-10)
        return vec;

    return BasicMath.mult(vec, 1.0 / norm);
}

From source file:com.dcits.govsbu.southernbase.baseproject2.modules.utils.Digests.java

/**
 * murmur32seed/*  ww  w .j av  a2  s . c  o  m*/
 */
public static int murmur32(byte[] input, int seed) {
    return Hashing.murmur3_32(seed).hashBytes(input).asInt();
}

From source file:com.dcits.govsbu.southernbase.baseproject2.modules.utils.Digests.java

/**
 * murmur32seed//w  w  w.j a v  a2s. c  om
 */
public static int murmur32(String input, int seed) {
    return Hashing.murmur3_32(seed).hashString(input, Charsets.UTF8).asInt();
}

From source file:com.dcits.govsbu.southernbase.baseproject2.modules.utils.Digests.java

/**
 * murmur32seed// w  w  w.j av  a  2 s .c  om
 */
public static int murmur32(String input, Charset charset, int seed) {
    return Hashing.murmur3_32(seed).hashString(input, charset).asInt();
}

From source file:edu.umd.marbl.mhap.utils.Utils.java

public final static int[] computeSequenceHashes(final String seq, final int kmerSize) {
    // RollingSequenceHash rabinHash = new RollingSequenceHash(kmerSize);
    // final int[] rabinHashes = rabinHash.hashInt(seq);

    HashFunction hf = Hashing.murmur3_32(0);

    int[] hashes = new int[seq.length() - kmerSize + 1];
    for (int iter = 0; iter < hashes.length; iter++) {
        HashCode hc = hf.newHasher().putUnencodedChars(seq.substring(iter, iter + kmerSize)).hash();
        hashes[iter] = hc.asInt();//from w w w. jav a 2  s.co m
    }

    return hashes;
}