List of usage examples for com.google.common.hash Hashing murmur3_32
public static HashFunction murmur3_32()
From source file:net.eusashead.spring.gaecache.Murmur3HashAlgorithm.java
/** * Returns a string containing each byte * a Murmurhash3 32 bit hash of this string * in order, as a two-digit unsigned hexadecimal * number in lower case/*from www . j a v a 2 s .co m*/ * @param key * @return */ public String hash(String key) { return Hashing.murmur3_32().hashBytes(key.getBytes(Charset.forName("UTF-8"))).toString(); }
From source file:ome.util.checksum.Murmur32ChecksumProviderImpl.java
public Murmur32ChecksumProviderImpl() { super(Hashing.murmur3_32()); }
From source file:edu.usc.pgroup.floe.flake.messaging.dispersion.elasticmapreducer.Murmur32.java
/** * Constructor. */ public Murmur32() { hash = Hashing.murmur3_32(); }
From source file:de.greenrobot.common.hash.otherhashes.Murmur3aGuavaChecksum.java
@Override public void reset() { hasher = Hashing.murmur3_32().newHasher(); }
From source file:info.yangguo.dragon.storage.mysql.algorithm.SingleKeyModuloTableShardingAlgorithm.java
@Override public String doEqualSharding(final Collection<String> availableTargetNames, final ShardingValue<String> shardingValue) { int index = Hashing.consistentHash(Hashing.murmur3_32().hashBytes(shardingValue.getValue().getBytes()), tbSum);//from w w w . j a v a2s . com for (String each : availableTargetNames) { if (each.endsWith(index + "")) { return each; } } throw new UnsupportedOperationException(); }
From source file:info.yangguo.dragon.storage.mysql.algorithm.SingleKeyModuloDatabaseShardingAlgorithm.java
@Override public String doEqualSharding(final Collection<String> availableTargetNames, final ShardingValue<String> shardingValue) { int index = Hashing.consistentHash(Hashing.murmur3_32().hashBytes(shardingValue.getValue().getBytes()), dbSum);//from w ww. j a va2s .c o m for (String each : availableTargetNames) { if (each.endsWith(index + "")) { return each; } } throw new UnsupportedOperationException(); }
From source file:org.apache.fluo.recipes.core.combine.InitializerImpl.java
public RowColumnValue convert(K key, V val) { byte[] k = serializer.serialize(key); int hash = Hashing.murmur3_32().hashBytes(k).asInt(); String bucketId = CombineQueueImpl.genBucketId(Math.abs(hash % numBuckets), numBuckets); BytesBuilder bb = Bytes.builder(dataPrefix.length() + bucketId.length() + 1 + k.length); Bytes row = bb.append(dataPrefix).append(bucketId).append(':').append(k).toBytes(); byte[] v = serializer.serialize(val); return new RowColumnValue(row, CombineQueueImpl.DATA_COLUMN, Bytes.of(v)); }
From source file:com.shenit.commons.utils.ShortLinkUtils.java
/** * Shorten url//ww w .j a v a 2 s . com * @param url URL that not encoded * @param query * @return */ public static String shorten(String url, String query, Object salt) { if (StringUtils.isEmpty(url)) return null; String joinStr = url.indexOf(HttpUtils.QUERY_CHAR) > 0 ? HttpUtils.QUERY_CHAR : HttpUtils.AMP; final String queryParams = (query != null) ? joinStr + query : StringUtils.EMPTY; String saltStr = DataUtils.toString(salt, StringUtils.EMPTY); url = toUrl((url + queryParams)); return StringUtils.isEmpty(url) ? null : Hashing.murmur3_32().hashString(url + HttpUtils.HASH_CHAR + saltStr, StandardCharsets.UTF_8) .toString(); }
From source file:io.airlift.slice.BenchmarkMurmur3Hash32.java
@Benchmark public int guava(BenchmarkData data, ByteCounter counter) { counter.add(data.getSlice().length()); return Hashing.murmur3_32().hashBytes(data.getBytes()).asInt(); }
From source file:org.apache.jackrabbit.oak.plugins.segment.standby.codec.BlobEncoder.java
@Override protected void encode(ChannelHandlerContext ctx, Blob b, ByteBuf out) throws Exception { byte[] bytes = null; InputStream s = b.getNewStream(); try {//from w w w. java2 s . c o m bytes = IOUtils.toByteArray(s); } finally { s.close(); } Hasher hasher = Hashing.murmur3_32().newHasher(); long hash = hasher.putBytes(bytes).hash().padToLong(); out.writeInt(bytes.length); out.writeByte(Messages.HEADER_BLOB); String bid = b.getContentIdentity(); byte[] id = bid.getBytes(Charset.forName("UTF-8")); out.writeInt(id.length); out.writeBytes(id); out.writeLong(hash); out.writeBytes(bytes); }