本文整理汇总了Java中net.openhft.hashing.LongHashFunction类的典型用法代码示例。如果您正苦于以下问题:Java LongHashFunction类的具体用法?Java LongHashFunction怎么用?Java LongHashFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LongHashFunction类属于net.openhft.hashing包,在下文中一共展示了LongHashFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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);
}
}
示例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);
}
}
示例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");
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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;
}
示例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()));
}
示例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));
}
示例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())));
}
示例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)));
}
示例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())));
}
示例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));
}
示例15: hashCode64
import net.openhft.hashing.LongHashFunction; //导入依赖的package包/类
@Override
public long hashCode64(int rowIndex, LongHashFunction hash) {
return super.hashCode64(rowIndex, hash);
}