本文整理汇总了Java中com.google.common.hash.Hashing.murmur3_128方法的典型用法代码示例。如果您正苦于以下问题:Java Hashing.murmur3_128方法的具体用法?Java Hashing.murmur3_128怎么用?Java Hashing.murmur3_128使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.hash.Hashing
的用法示例。
在下文中一共展示了Hashing.murmur3_128方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FastBloomFilter
import com.google.common.hash.Hashing; //导入方法依赖的package包/类
public FastBloomFilter(int bits, int numberHashFunctions) {
bs = new BitSet(bits);
Random r = new Random(System.currentTimeMillis());
hashFunctions = new HashFunction[numberHashFunctions];
for (int i=0; i<numberHashFunctions; ++i) {
hashFunctions[i] = Hashing.murmur3_128(r.nextInt());
}
capacity = bits;
}
示例2: Function0
import com.google.common.hash.Hashing; //导入方法依赖的package包/类
@JsonCreator
public Function0(@JsonProperty("seed") int seed,
@JsonProperty("fiberNum") int fiberNum)
{
this.seed = seed;
this.fiberNum = fiberNum;
this.hasher = Hashing.murmur3_128(seed);
}
示例3: FeatureHash
import com.google.common.hash.Hashing; //导入方法依赖的package包/类
private FeatureHash(int hashBucketSize,
int hashSeed,
String hashFeaturePrefix) {
this.hashBucketSize = hashBucketSize;
this.hashFeaturePrefix = hashFeaturePrefix;
this.murmurHash = Hashing.murmur3_128(hashSeed);
}
示例4: forName
import com.google.common.hash.Hashing; //导入方法依赖的package包/类
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:
throw new IllegalArgumentException("Can't find hash function with name " + name);
}
}
示例5: forName
import com.google.common.hash.Hashing; //导入方法依赖的package包/类
/** Return the hash function corresponding to a given message-digest algorithm given by name.
*
* @param messageDigest a message-digest algorithm (e.g., <code>MurmurHash3</code> or <code>MD5</code>); {@code null} if {@code messageDigest} is the empty string.
*/
@SuppressWarnings("deprecation")
public final static HashFunction forName(final String messageDigest) throws NoSuchAlgorithmException {
if ("".equals(messageDigest)) return null;
if ("MD5".equalsIgnoreCase(messageDigest)) return Hashing.md5();
if ("MurmurHash3".equalsIgnoreCase(messageDigest)) return Hashing.murmur3_128();
throw new NoSuchAlgorithmException("Unknown hash function " + messageDigest);
}
示例6: RendezvousHash
import com.google.common.hash.Hashing; //导入方法依赖的package包/类
public RendezvousHash(Funnel<N> nodeFunnel, Collection<N> init) {
this.hasher = Hashing.murmur3_128();
this.nodeFunnel = nodeFunnel;
nodeList.addAll(init);
}
示例7: main
import com.google.common.hash.Hashing; //导入方法依赖的package包/类
public static void main(String []args) {
FeatureHash featureHash = FeatureHash.build(10, 111311, "hash_").withDelim(",", ":");
String featureline = "1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1";
List<String> flist = Lists.newArrayList(StringUtils.split("1,2,3,4,5,6,7,8,9", ","));
List<Tuple<String, Float>> ftlist = new ArrayList<>();
for (int i = 1; i <= 9; i++) {
ftlist.add(new Tuple<>(i + "", 1.0f));
}
System.out.println("feature line:" + featureline);
System.out.println("hash map 2 map:" + featureHash.hashMap2Map(parse(featureline, ",", ":")));
System.out.println("hash map 2 map:" + featureHash.hashMap2Map(parse(featureline, ",", ":")));
System.out.println("hash list 2 map:" + featureHash.hashList2Map(flist));
System.out.println("hash list 2 map:" + featureHash.hashList2Map(flist));
System.out.println("hash tuple list 2 map:" + featureHash.hashPairList2Map(ftlist));
System.out.println("hash tuple list 2 map:" + featureHash.hashPairList2Map(ftlist));
System.out.println("hash line 2 map:" + featureHash.hashLine2Map(featureline));
System.out.println("hash line 2 map:" + featureHash.hashLine2Map(featureline));
System.out.println("hash map 2 line:" + featureHash.hashMap2Line(parse(featureline, ",", ":")));
System.out.println("hash map 2 line:" + featureHash.hashMap2Line(parse(featureline, ",", ":")));
System.out.println("hash list 2 line:" + featureHash.hashList2Line(flist));
System.out.println("hash list 2 line:" + featureHash.hashList2Line(flist));
System.out.println("hash line 2 line:" + featureHash.hashLine2Line(featureline));
System.out.println("hash line 2 line:" + featureHash.hashLine2Line(featureline));
int time = 10000000;
int size = 10;
long start = System.currentTimeMillis();
int cnt[] = new int[size];
int signcnt[] = new int[2];
HashFunction hashFunction = Hashing.murmur3_128(111);
for (int i = 0; i < time; i++) {
// cnt[featureHash.hash("fsfdsfdsf" + i) % size] ++;
// signcnt[featureHash.signhash("fsfdsfdsf" + i) + 1] ++;
long longhash = hashFunction.hashString("fsfdsfdsf" + i,
Charset.defaultCharset()).asLong();
int fhash = (int)((longhash & 0x7fffffffL) % size);
float signhash = 2.0f * ((longhash & 0x10000000000L) >> 40) - 1.0f;
cnt[fhash] ++;
int sign = 0;
if (signhash < 0) {
sign = 0;
} else {
sign = 1;
}
signcnt[sign] ++;
}
long end = System.currentTimeMillis();
System.out.println("takes:" + time * 1000. / (end - start));
for (int i = 0; i < size; i++) {
System.out.println(i + ":" + cnt[i] * 1.0 / time);
}
System.out.println(signcnt[0] * 1.0 / time);
System.out.println(signcnt[1] * 1.0 / time);
// for (int i = 0; i < 20; i++) {
// System.out.println(featureHash.hash("xx"));
// System.out.println(featureHash.hash("yy"));
// }
}