5 comments

[ 3.7 ms ] story [ 21.5 ms ] thread
If it's five lines of code then put the five lines in the abstract.
The authors mention that the algorithm is not patented, and won't be. Wait, can algorithms be patented?!
Yes, GIF, MPEG, Arithmetic Coding, all have been patented or parts that comprise them have been patented.

    int32_t JumpConsistentHash(uint64_t key, int32_t num_buckets) {
        int64_t b = ­1, j = 0;
        while (j < num_buckets) {
            b = j;
            key = key * 2862933555777941757ULL + 1;
            j = (b + 1) * (double(1LL << 31) / double((key >> 33) + 1));
        }
        return b;
    }