List of usage examples for com.google.common.hash Hashing murmur3_32
public static HashFunction murmur3_32(int seed)
From source file:edu.umd.marbl.mhap.sketch.HashUtils.java
public final static int[] computeHashesIntInt(int 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().putInt(obj).putInt(iter).hash(); hashes[iter] = hc.asInt();// w w w. jav a2s . com } return hashes; }
From source file:org.knime.ext.textprocessing.nodes.transformation.documentvectorhashing.Murmur3_32bitHashingFunction.java
/** * {@inheritDoc}/*from w ww .j a v a 2 s . c o m*/ */ @Override public int hash(final String term, final int seed) { HashFunction hash = Hashing.murmur3_32(seed); HashCode hashCode = hash.hashString(term, Charsets.UTF_8); return hashCode.asInt(); }
From source file:edu.umd.marbl.mhap.sketch.HashUtils.java
public final static int[] computeHashesIntLong(long 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().putLong(obj).putInt(iter).hash(); hashes[iter] = hc.asInt();/* www . ja v a2s. c o m*/ } return hashes; }
From source file:org.opencloudb.route.function.PartitionByMurmurHash.java
private void generateBucketMap() { hash = Hashing.murmur3_32(seed);// for (int i = 0; i < count; i++) {//TreeMap StringBuilder hashName = new StringBuilder("SHARD-").append(i); for (int n = 0, shard = virtualBucketTimes * getWeight(i); n < shard; n++) { bucketMap.put(hash.hashUnencodedChars(hashName.append("-NODE-").append(n)).asInt(), i); }// ww w . ja v a 2 s.c om } weightMap = null; }
From source file:com.mirth.connect.donkey.server.queue.DestinationQueue.java
public DestinationQueue(String groupBy, int threadCount, boolean regenerateTemplate, Serializer serializer, MessageMaps messageMaps) {/*from w ww . j a v a 2s . c o m*/ this.groupBy = StringUtils.defaultString(groupBy); this.regenerateTemplate = regenerateTemplate; this.serializer = serializer; this.messageMaps = messageMaps; if (StringUtils.isNotBlank(groupBy)) { queueBuckets = threadCount; if (queueBuckets > 1) { queueThreadIds = new ArrayList<Long>(queueBuckets); hashFunction = Hashing.murmur3_32((int) System.currentTimeMillis()); initialThreadAssignmentMap = new ConcurrentHashMap<String, Integer>(queueBuckets); } } }
From source file:edu.umd.marbl.mhap.sketch.HashUtils.java
public final static int[] computeHashesIntString(String 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().putUnencodedChars(obj).putInt(iter).hash(); hashes[iter] = hc.asInt();/*ww w . j a v a 2s . c o m*/ } return hashes; }
From source file:edu.umd.marbl.mhap.sketch.HashUtils.java
public final static int[] computeSequenceHashes(final String seq, final int nGramSize) { HashFunction hf = Hashing.murmur3_32(0); int[] hashes = new int[seq.length() - nGramSize + 1]; for (int iter = 0; iter < hashes.length; iter++) { HashCode hc = hf.newHasher().putUnencodedChars(seq.substring(iter, iter + nGramSize)).hash(); hashes[iter] = hc.asInt();// w w w . ja v a 2 s.com } return hashes; }
From source file:me.j360.dubbo.modules.util.text.HashUtil.java
/** * murmur32, ?/*from ww w .ja v a 2 s. c om*/ */ public static int murmur32AsInt(@NotNull byte[] input) { return Hashing.murmur3_32(MURMUR_SEED).hashBytes(input).asInt(); }
From source file:org.apache.pig.newplan.logical.relational.LogicalPlan.java
/** * Returns the signature of the LogicalPlan. The signature is a unique identifier for a given * plan generated by a Pig script. The same script run multiple times with the same version of * Pig is guaranteed to produce the same signature, even if the input or output locations differ. * * @return a unique identifier for the logical plan * @throws FrontendException if signature can't be computed *//*from w ww .java 2 s . c o m*/ public String getSignature() throws FrontendException { // Use a streaming hash function. We use a murmur_32 function with a constant seed, 0. HashFunction hf = Hashing.murmur3_32(0); HashOutputStream hos = new HashOutputStream(hf); PrintStream ps = new PrintStream(hos); LogicalPlanPrinter printer = new LogicalPlanPrinter(this, ps); printer.visit(); return Integer.toString(hos.getHashCode().asInt()); }
From source file:me.j360.dubbo.modules.util.text.HashUtil.java
/** * murmur32, ?/*from ww w . j a v a2 s .co m*/ */ public static int murmur32AsInt(@NotNull String input) { return Hashing.murmur3_32(MURMUR_SEED).hashString(input, Charsets.UTF_8).asInt(); }