当前位置: 首页>>代码示例>>Java>>正文


Java LongHashFunction类代码示例

本文整理汇总了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();
    }
}
 
开发者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


注:本文中的net.openhft.hashing.LongHashFunction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。