Hydra.Core.Sharding.JumpSharding.JumpConsistentHash C# (CSharp) Method

JumpConsistentHash() static private method

static private JumpConsistentHash ( System.UInt64 key, Int32 buckets ) : Int32
key System.UInt64
buckets System.Int32
return System.Int32
        static Int32 JumpConsistentHash(UInt64 key, Int32 buckets)
        {
            Int64 b = 1;
            Int64 j = 0;

            while (j < buckets)
            {
                b = j;
                key = key * 2862933555777941757 + 1;

                var x = (Double)(b + 1);
                var y = (Double)(((Int64)(1)) << 31);
                var z = (Double)((key >> 33) + 1);

                j = (Int64)(x * (y / z));
            }

            return (Int32)b;
        }