本文整理汇总了Java中net.openhft.hashing.LongHashFunction类的典型用法代码示例。如果您正苦于以下问题:Java LongHashFunction类的具体用法?Java LongHashFunction怎么用?Java LongHashFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LongHashFunction类属于net.openhft.hashing包,在下文中一共展示了LongHashFunction类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: hashToBase64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
public static String hashToBase64(ByteBuf objectState) {
ByteBuffer bf = objectState.internalNioBuffer(objectState.readerIndex(), objectState.readableBytes());
long h1 = LongHashFunction.farmUo().hashBytes(bf);
long h2 = LongHashFunction.xx().hashBytes(bf);
ByteBuf buf = ByteBufAllocator.DEFAULT.buffer((2 * Long.SIZE) / Byte.SIZE);
try {
buf.writeLong(h1).writeLong(h2);
ByteBuf b = Base64.encode(buf);
try {
String s = b.toString(CharsetUtil.UTF_8);
return s.substring(0, s.length() - 2);
} finally {
b.release();
}
} finally {
buf.release();
}
}
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:Hash.java
示例2: emit
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
public void emit(K key, V value) {
try {
ByteBuf encodedKey = codec.getValueEncoder().encode(key);
long hash = LongHashFunction.xx().hashBytes(encodedKey.internalNioBuffer(encodedKey.readerIndex(), encodedKey.readableBytes()));
encodedKey.release();
int part = (int) Math.abs(hash % parts);
String partName = name + ":" + part;
RListMultimap<K, V> multimap = client.getListMultimap(partName, codec);
multimap.put(key, value);
if (timeout > 0 && !expirationsBitSet.get(part)) {
multimap.expire(timeout, TimeUnit.MILLISECONDS);
expirationsBitSet.set(part);
}
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:Collector.java
示例3: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
@SuppressWarnings("ConstantConditions")
public long hashCode64(int rowIndex, LongHashFunction hash) {
assert !isMissing(rowIndex);
switch (this.description.kind) {
case Category:
case String:
case Json:
return hash.hashChars(this.getString(rowIndex));
case Integer:
return hash.hashInt(this.getInt(rowIndex));
case Date:
case Double:
case Duration:
return hash.hashLong(Double.doubleToRawLongBits(this.asDouble(rowIndex,
NoStringConverter.getConverterInstance())));
default:
throw new RuntimeException("Unexpected kind " + this.description.kind);
}
}
开发者ID:vmware,项目名称:hillview,代码行数:21,代码来源:SparseColumn.java
示例4: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
public long hashCode64(int rowIndex, LongHashFunction hash) {
if (this.isMissing(rowIndex))
return MISSING_HASH_VALUE;
switch (ObjectArrayColumn.this.description.kind) {
case Category:
case Json:
case String:
return hash.hashChars(Converters.checkNull(this.getString(rowIndex)));
case Date:
return hash.hashLong(Double.doubleToLongBits(Converters.toDouble(
Converters.checkNull(this.getDate(rowIndex)))));
case Integer:
return hash.hashInt(this.getInt(rowIndex));
case Double:
return hash.hashLong(Double.doubleToLongBits(this.getDouble(rowIndex)));
case Duration:
return hash.hashLong(Double.doubleToLongBits(Converters.toDouble(
Converters.checkNull(this.getDuration(rowIndex)))));
default:
throw new RuntimeException("Unexpected data type");
}
}
开发者ID:vmware,项目名称:hillview,代码行数:24,代码来源:ObjectArrayColumn.java
示例5: hash
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
private long[] hash(Object object) {
ByteBuf state = encode(object);
try {
long hash1 = LongHashFunction.xx().hashBytes(state.internalNioBuffer(state.readerIndex(), state.readableBytes()));
long hash2 = LongHashFunction.farmUo().hashBytes(state.internalNioBuffer(state.readerIndex(), state.readableBytes()));
return new long[] {hash1, hash2};
} finally {
state.release();
}
}
开发者ID:qq1588518,项目名称:JRediClients,代码行数:11,代码来源:RedissonBloomFilter.java
示例6: hash
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
public static byte[] hash(ByteBuf objectState) {
ByteBuffer b = objectState.internalNioBuffer(objectState.readerIndex(), objectState.readableBytes());
long h1 = LongHashFunction.farmUo().hashBytes(b);
long h2 = LongHashFunction.xx().hashBytes(b);
ByteBuf buf = ByteBufAllocator.DEFAULT.buffer((2 * Long.SIZE) / Byte.SIZE);
try {
buf.writeLong(h1).writeLong(h2);
byte[] dst = new byte[buf.readableBytes()];
buf.readBytes(dst);
return dst;
} finally {
buf.release();
}
}
开发者ID:qq1588518,项目名称:JRediClients,代码行数:16,代码来源:Hash.java
示例7: createHLL
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
/**
* Creates a Hyperloglog data structure from a column and membership set. Uses the hash code
* of the objects in the column as identifier.
*/
public void createHLL(IColumn column, IMembershipSet memSet) {
final IRowIterator myIter = memSet.getIterator();
LongHashFunction hash = LongHashFunction.xx(this.seed);
int currRow = myIter.getNextRow();
while (currRow >= 0) {
if (!column.isMissing(currRow)) {
this.add(column.hashCode64(currRow, hash));
}
currRow = myIter.getNextRow();
}
this.distinctItemsEstimator();
}
开发者ID:vmware,项目名称:hillview,代码行数:17,代码来源:HLogLog.java
示例8: transform
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
public static String transform(byte[] bytes) {
long hash = LongHashFunction.xx().hashBytes(bytes);
if (stringCache.containsKey(hash)) {
return stringCache.get(hash);
}
for (int i = 0; i < bytes.length; i++) {
if (bytes[i] == 0) {
bytes[i] = 32;
}
}
String string = new String(bytes).split(" ")[0].trim().intern();
stringCache.put(hash, string);
return string;
}
开发者ID:Jonatino,项目名称:Java-Memory-Manipulation,代码行数:15,代码来源:Strings.java
示例9: register
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
public static final void register(final Map<String, Hasher> hashers) {
hashers.put(ZeroAllocHasher.CITY_1_1,
new ZeroAllocHasher(LongHashFunction.city_1_1()));
hashers.put(ZeroAllocHasher.FARM_NA,
new ZeroAllocHasher(LongHashFunction.farmNa()));
hashers.put(ZeroAllocHasher.FARM_UO,
new ZeroAllocHasher(LongHashFunction.farmUo()));
hashers.put(ZeroAllocHasher.MURMUR_3,
new ZeroAllocHasher(LongHashFunction.murmur_3()));
hashers.put(ZeroAllocHasher.XXH64,
new ZeroAllocHasher(LongHashFunction.xx_r39()));
}
开发者ID:benalexau,项目名称:hash-bench,代码行数:13,代码来源:ZeroAllocHasher.java
示例10: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
default long hashCode64(int rowIndex, LongHashFunction hash) {
assert !this.isMissing(rowIndex);
return hash.hashInt(this.getInt(rowIndex));
}
开发者ID:vmware,项目名称:hillview,代码行数:6,代码来源:IIntColumn.java
示例11: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
default long hashCode64(int rowIndex, LongHashFunction hash) {
assert !isMissing(rowIndex);
return hash.hashLong(Double.doubleToRawLongBits(this.asDouble(rowIndex,
NoStringConverter.getConverterInstance())));
}
开发者ID:vmware,项目名称:hillview,代码行数:7,代码来源:IDateColumn.java
示例12: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
default long hashCode64(int rowIndex, LongHashFunction hash) {
assert !isMissing(rowIndex);
return hash.hashLong(Double.doubleToRawLongBits(this.getDouble(rowIndex)));
}
开发者ID:vmware,项目名称:hillview,代码行数:6,代码来源:IDoubleColumn.java
示例13: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
default long hashCode64(int rowIndex, LongHashFunction hash) {
assert !isMissing(rowIndex);
return hash.hashLong(Double.doubleToRawLongBits(this.asDouble(rowIndex,
NoStringConverter.getConverterInstance())));
}
开发者ID:vmware,项目名称:hillview,代码行数:7,代码来源:IDurationColumn.java
示例14: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
default long hashCode64(int rowIndex, LongHashFunction hash) {
assert !isMissing(rowIndex);
//noinspection ConstantConditions
return hash.hashChars(this.getString(rowIndex));
}
开发者ID:vmware,项目名称:hillview,代码行数:7,代码来源:IStringColumn.java
示例15: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
public long hashCode64(int rowIndex, LongHashFunction hash) {
return super.hashCode64(rowIndex, hash);
}
开发者ID:vmware,项目名称:hillview,代码行数:5,代码来源:DateListColumn.java
示例16: ZeroAllocHasher
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
private ZeroAllocHasher(final LongHashFunction delegate) {
this.delegate = delegate;
}
开发者ID:benalexau,项目名称:hash-bench,代码行数:4,代码来源:ZeroAllocHasher.java
示例17: keySegmentDistributionTest
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
public void keySegmentDistributionTest(int size, int segments) {
ChronicleMap<CharSequence, Integer> map = ChronicleMapBuilder
.of(CharSequence.class, Integer.class)
.actualSegments(segments)
// TODO problems with computing proper number of segments/chunks
// when I write this without `* 2` I expect not to have ISE "segment is full"...
.entries(size * 2)
.averageKeySize(10)
.create();
byte[] keyBytes = new byte[10];
ThreadLocalRandom random = ThreadLocalRandom.current();
for (int i = 0; i < size; i++) {
random.nextBytes(keyBytes);
String key = new String(keyBytes, StandardCharsets.US_ASCII);
long hash = LongHashFunction.xx_r39().hashBytes(StandardCharsets.UTF_8.encode(key));
int segmentIndex = (((int) hash) & Integer.MAX_VALUE) % segments;
// Put the segment index as a value to the map
map.put(key, segmentIndex);
}
// The following loop checks that internally hash code and segment index is chosen
// the same way as we explicitly computed in this test. Since ChMap iteration is segment
// by segment, we expect to see the sequence of values 0, 0, ... 0, 1, ..1, 2, ..2, 3, ..3
// or opposite -- 3, 3, ... 3, 2, ..2, 1, ..1, 0, ..0
int currentSegment = -1;
boolean ascendingDirection = false;
for (Integer entrySegment : map.values()) {
if (currentSegment == -1) {
currentSegment = entrySegment;
if (currentSegment == 0) {
ascendingDirection = true;
}
} else {
if (ascendingDirection) {
Assert.assertTrue(entrySegment >= currentSegment);
currentSegment = entrySegment;
} else {
// descending iteration direction
Assert.assertTrue(entrySegment <= currentSegment);
currentSegment = entrySegment;
}
}
}
}
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:45,代码来源:KeySegmentDistributionTest.java
示例18: getHash
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
private long getHash(String text) {
return LongHashFunction.xx_r39().hash(text,
LOWER_CASE_ACCESS_INSTANCE, 0, text.length());
}
开发者ID:apiman,项目名称:apiman,代码行数:5,代码来源:CaseInsensitiveStringMultiMap.java
示例19: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
/**
* @return A 64 bit hash code for the item in the rowIndex.
* returns MISSING_HASH_VALUE if item is missing.
*/
long hashCode64(int rowIndex, LongHashFunction hash);
开发者ID:vmware,项目名称:hillview,代码行数:6,代码来源:IColumn.java
注:本文中的net.openhft.hashing.LongHashFunction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论