Пример #1
0
        //default String.GetHashCode() can't well spread strings like "1", "2", "3"
        static int BetterHash(string key)
        {
            //return KetamaHash.Utils.HashAlgorithm.hash(KetamaHash.Utils.HashAlgorithm.computeMd5(key),0);
            uint hash = MurmurHash2.Hash(Encoding.ASCII.GetBytes(key));

            return((int)hash);
        }
Пример #2
0
        /// <summary>
        /// 获取指定键的节点。
        /// </summary>
        /// <param name="key">键。</param>
        /// <returns>返回一个节点。</returns>
        public TNode GetNode(byte[] key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            int hash  = (int)MurmurHash2.Hash(key);
            int first = First_ge(this._keys, hash);

            return(this._circle[this._keys[first]]);
        }