public T Get(string input) { var data = Encoding.UTF8.GetBytes(input); var val = hash.Hash(data); return(Get(val)); }
private int GetPartitionIndex(object partitionKey) { ASCIIEncoding encoding = new ASCIIEncoding(); MurmurHash2Simple hasher = new MurmurHash2Simple(); int bytes = (int)hasher.Hash(encoding.GetBytes((string)partitionKey)); int partitionIndex = Math.Abs(bytes % this.partitions.Count); return(partitionIndex); }
private int GetHash(string value) { MurmurHash2Simple simple = new MurmurHash2Simple(); if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException(nameof(value)); } if (value.Length > _maxSize) { throw new ArgumentException($"Максимальная длинна ключа составляет {_maxSize} символов.", nameof(value)); } var hash = Convert.ToInt32(simple.Hash(System.Text.Encoding.UTF8.GetBytes(value))); return(hash); }
/// <summary> /// turns string into representative (murmur2) uint hash /// </summary> /// <param name="hash"></param> /// <param name="dataset_column"></param> /// <returns></returns> public static uint get_representative_int_hash(MurmurHash2Simple hash, string dataset_column) { return(hash.Hash(Encoding.UTF8.GetBytes(dataset_column))); }
private int GetPartitionIndex(object partitionKey) { ASCIIEncoding encoding = new ASCIIEncoding(); MurmurHash2Simple hasher = new MurmurHash2Simple(); int bytes = (int)hasher.Hash(encoding.GetBytes((string)partitionKey)); int partitionIndex = Math.Abs(bytes % this.partitions.Count); return partitionIndex; }