本文整理汇总了Java中org.apache.cassandra.utils.MurmurHash类的典型用法代码示例。如果您正苦于以下问题:Java MurmurHash类的具体用法?Java MurmurHash怎么用?Java MurmurHash使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MurmurHash类属于org.apache.cassandra.utils包,在下文中一共展示了MurmurHash类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getToken
import org.apache.cassandra.utils.MurmurHash; //导入依赖的package包/类
/**
* Generate the token of a key.
* Note that we need to ensure all generated token are strictly bigger than MINIMUM.
* In particular we don't want MINIMUM to correspond to any key because the range (MINIMUM, X] doesn't
* include MINIMUM but we use such range to select all data whose token is smaller than X.
*/
public LongToken getToken(ByteBuffer key)
{
if (key.remaining() == 0)
return MINIMUM;
long[] hash = new long[2];
MurmurHash.hash3_x64_128(key, key.position(), key.remaining(), 0, hash);
return new LongToken(normalize(hash[0]));
}
示例2: GeneratorConfig
import org.apache.cassandra.utils.MurmurHash; //导入依赖的package包/类
public GeneratorConfig(String seedStr, DistributionFactory clusteringDistributions, DistributionFactory sizeDistributions, DistributionFactory identityDistributions)
{
this.clusteringDistributions = clusteringDistributions;
this.sizeDistributions = sizeDistributions;
this.identityDistributions = identityDistributions;
ByteBuffer buf = ByteBufferUtil.bytes(seedStr);
long[] hash = new long[2];
MurmurHash.hash3_x64_128(buf, buf.position(), buf.remaining(), 0, hash);
salt = hash[0];
}
示例3: getToken
import org.apache.cassandra.utils.MurmurHash; //导入依赖的package包/类
/**
* Generate the token of a key.
* Note that we need to ensure all generated token are strictly bigger than MINIMUM.
* In particular we don't want MINIMUM to correspond to any key because the range (MINIMUM, X] doesn't
* include MINIMUM but we use such range to select all data whose token is smaller than X.
*/
public LongToken getToken(ByteBuffer key)
{
if (key.remaining() == 0)
return MINIMUM;
long hash = MurmurHash.hash3_x64_128(key, key.position(), key.remaining(), 0)[0];
return new LongToken(normalize(hash));
}
示例4: dk
import org.apache.cassandra.utils.MurmurHash; //导入依赖的package包/类
private static DecoratedKey dk(Long token)
{
ByteBuffer buf = ByteBuffer.allocate(8);
buf.putLong(token);
buf.flip();
Long hashed = MurmurHash.hash2_64(buf, buf.position(), buf.remaining(), 0);
return new DecoratedKey(new LongToken(hashed), buf);
}
示例5: getHash
import org.apache.cassandra.utils.MurmurHash; //导入依赖的package包/类
private long[] getHash(ByteBuffer key)
{
long[] hash = new long[2];
MurmurHash.hash3_x64_128(key, key.position(), key.remaining(), 0, hash);
return hash;
}
示例6: filterHash
import org.apache.cassandra.utils.MurmurHash; //导入依赖的package包/类
public void filterHash(long[] dest)
{
ByteBuffer key = getKey();
MurmurHash.hash3_x64_128(key, key.position(), key.remaining(), 0, dest);
}
示例7: addKey
import org.apache.cassandra.utils.MurmurHash; //导入依赖的package包/类
public MetadataCollector addKey(ByteBuffer key)
{
long hashed = MurmurHash.hash2_64(key, key.position(), key.remaining(), 0);
cardinality.offerHashed(hashed);
return this;
}
示例8: keyAt
import org.apache.cassandra.utils.MurmurHash; //导入依赖的package包/类
private static DecoratedKey keyAt(long rawKey)
{
ByteBuffer key = ByteBuffer.wrap(("key" + rawKey).getBytes());
return new DecoratedKey(new LongToken(MurmurHash.hash2_64(key, key.position(), key.remaining(), 0)), key);
}
示例9: addKey
import org.apache.cassandra.utils.MurmurHash; //导入依赖的package包/类
public void addKey(ByteBuffer key)
{
long hashed = MurmurHash.hash2_64(key, key.position(), key.remaining(), 0);
cardinality.offerHashed(hashed);
}