List of usage examples for com.google.common.primitives UnsignedLong doubleValue
@Override public double doubleValue()
From source file:com.streametry.jumphash.JumpHash.java
/** Jump Consistent Hashing algorithm * * @param buckets number of buckets/*from ww w .j av a 2 s . c o m*/ * @param keyHash hash of a key * @return selected bucket */ public static int consistent(int buckets, long keyHash) { UnsignedLong key = fromLongBits(keyHash); long b = -1, j = 0; while (j < buckets) { b = j; key = key.times(constant).plus(ONE); UnsignedLong keyShift = fromLongBits(key.longValue() >>> 33).plus(ONE); j = (long) ((b + 1) * (constant2 / keyShift.doubleValue())); } return (int) b; }