Example usage for com.google.common.primitives UnsignedLong times

List of usage examples for com.google.common.primitives UnsignedLong times

Introduction

In this page you can find the example usage for com.google.common.primitives UnsignedLong times.

Prototype

@CheckReturnValue
public UnsignedLong times(UnsignedLong val) 

Source Link

Document

Returns the result of multiplying this and val .

Usage

From source file:com.streametry.jumphash.JumpHash.java

/** Jump Consistent Hashing algorithm
 *
 * @param buckets number of buckets//w ww .j  a  va  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;
}