Here you can find the source of longToBucket(long key, int buckets)
public static final int longToBucket(long key, int buckets)
//package com.java2s; //License from project: Open Source License public class Main { public static final int longToBucket(long key, int buckets) { key = (~key) + (key << 18); // key = (key << 18) - key - 1; key ^= (key >>> 31);/*from ww w.j a va 2s . c o m*/ key *= 21; // key = (key + (key << 2)) + (key << 4); key ^= (key >>> 11); key += (key << 6); key ^= (key >>> 22); int result = ((int) key) % buckets; return result < 0 ? result + buckets : result; } }