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

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

Introduction

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

Prototype

public static HashFunction murmur3_128() 

Source Link

Document

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

Usage

From source file:com.qwazr.utils.HashUtils.java

public static final int getMurmur3Mod(final String hashString, Charset charset, final int mod) {
    HashFunction m3 = Hashing.murmur3_128();
    if (charset == null)
        charset = Charset.defaultCharset();
    return (Math.abs(m3.hashString(hashString, charset).asInt()) % mod);
}

From source file:org.thingsboard.server.utils.MiscUtils.java

public static HashFunction forName(String name) {
    switch (name) {
    case "murmur3_32":
        return Hashing.murmur3_32();
    case "murmur3_128":
        return Hashing.murmur3_128();
    case "crc32":
        return Hashing.crc32();
    case "md5":
        return Hashing.md5();
    default:/*from   ww  w. j  a v  a 2  s  .c  o m*/
        throw new IllegalArgumentException("Can't find hash function with name " + name);
    }
}

From source file:org.sfs.io.Block.java

protected static byte[] checksum(byte[] data) {
    return Hashing.murmur3_128().hashBytes(data).asBytes();
}

From source file:com.lithium.flow.util.HashFunctions.java

@Nonnull
public static HashFunction of(@Nonnull String name) {
    checkNotNull(name);/*from w ww .j  a  v  a  2 s  .  com*/
    switch (name) {
    case "adler32":
        return Hashing.adler32();
    case "crc32":
        return Hashing.crc32();
    case "md5":
        return Hashing.md5();
    case "sha1":
        return Hashing.sha1();
    case "sha256":
        return Hashing.sha256();
    case "sha512":
        return Hashing.sha512();
    case "sipHash24":
        return Hashing.sipHash24();
    case "murmur3_32":
        return Hashing.murmur3_32();
    case "murmur3_128":
        return Hashing.murmur3_128();
    default:
        throw new RuntimeException("unknown hash: " + name);
    }
}

From source file:norbert.mynemo.dataimport.StringUserDataModel.java

/**
 * Returns the hash of the given user name.
 *
 * @param name a user name/*from   w  w  w .j a  va  2  s .com*/
 * @return the hash of the user name
 */
public static long convertUsername(String name) {
    HashFunction hashFonction = Hashing.murmur3_128();
    return hashFonction.newHasher().putString(name, Charsets.UTF_8).hash().asLong();
}

From source file:com.ambimmort.rmr.client.Client.java

public Client(List<Connection> cps) {
    this.cps = cps;
    connectionsPoints = new ConsistentHash<Connection>(Hashing.murmur3_128(), cps.size(), cps);
}

From source file:com.streamsets.pipeline.lib.hashing.HashingUtil.java

public static HashFunction getHasher(String hashAlgorithm) {
    switch (hashAlgorithm) {
    case "murmur3_128":
        return Hashing.murmur3_128();
    case "MD5":
        return Hashing.md5();
    case "SHA-1":
        return Hashing.sha1();
    case "SHA-256":
        return Hashing.sha256();
    default:/*from   w ww. java  2s . c  o  m*/
        throw new IllegalArgumentException(Utils.format("Unsupported Hashing Algorithm: {}", hashAlgorithm));
    }
}

From source file:com.picdrop.io.repository.MurmurFileRepository.java

public MurmurFileRepository(String rootdir) {
    super(rootdir);
    this.hashf = Hashing.murmur3_128();
}

From source file:com.picdrop.io.writer.MurmurFileReaderWriter.java

@Inject
public MurmurFileReaderWriter(@Named("service.file.store") String rootdir) {
    this.hashf = Hashing.murmur3_128();
    this.rootdir = new File(rootdir);
    if (!this.rootdir.exists() || !this.rootdir.canWrite() || !this.rootdir.isDirectory()) {
        throw new IllegalArgumentException(String.format("the dir '%s' is not accessible", rootdir));
    }/*from  w  ww .j  a v  a 2 s.  c  o m*/
}

From source file:com.ambimmort.rmr.client.Client.java

public Client() {
    this.cps = new ArrayList<Connection>();
    connectionsPoints = new ConsistentHash<Connection>(Hashing.murmur3_128(), cps.size(), cps);
}