Ejemplo n.º 1
0
        /// <summary>
        /// Generate a deterministic Guid from a queue Id.
        /// </summary>
        /// <param name="queueId"></param>
        /// <returns></returns>
        private Guid GenerateDeterministicGuid(QueueId queueId)
        {
            // provider name hash code
            int providerNameGuidHash = (int)JenkinsHash.ComputeHash(this.Name);

            // get queueId hash code
            uint queueIdHash = queueId.GetUniformHashCode();

            byte[] queIdHashByes = BitConverter.GetBytes(queueIdHash);
            short  s1            = BitConverter.ToInt16(queIdHashByes, 0);
            short  s2            = BitConverter.ToInt16(queIdHashByes, 2);

            // build guid tailing 8 bytes from providerNameGuidHash and queIdHashByes.
            var tail = new List <byte>();

            tail.AddRange(BitConverter.GetBytes(providerNameGuidHash));
            tail.AddRange(queIdHashByes);

            // make guid.
            // - First int is provider name hash
            // - Two shorts from queue Id hash
            // - 8 byte tail from provider name hash and queue Id hash.
            return(new Guid(providerNameGuidHash, s1, s2, tail.ToArray()));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// <see cref="IHasher.Hash(byte[])"/>.
 /// </summary>
 public int Hash(byte[] data)
 {
     return(unchecked ((int)JenkinsHash.ComputeHash(data)));
 }
Ejemplo n.º 3
0
 public uint GenerateHash(ulong Key)
 {
     return(JenkinsHash.ComputeHash(BitConverter.GetBytes(Key)));
 }
Ejemplo n.º 4
0
 public uint GenerateHash(Guid Key)
 {
     return(JenkinsHash.ComputeHash(Key.ToByteArray()));
 }
Ejemplo n.º 5
0
 public uint GenerateHash(string Key)
 {
     return(JenkinsHash.ComputeHash(Key));
 }
Ejemplo n.º 6
0
 public TypeKey(byte[] key)
 {
     HashCode = unchecked ((int)JenkinsHash.ComputeHash(key));
     TypeName = key;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Performs the Jenkins hash on an input byte array
        /// </summary>
        public static byte[] JenkinsHash( byte[] input )
        {
            using ( JenkinsHash jHash = new JenkinsHash() )
            {
                byte[] hash = jHash.ComputeHash( input );
                Array.Reverse( hash );

                return hash;
            }
        }
Ejemplo n.º 8
0
 private static int GetHashCode(byte[] value) => (int)JenkinsHash.ComputeHash(value);
Ejemplo n.º 9
0
 internal StreamId(byte[] fullKey, ushort keyIndex)
     : this(fullKey, keyIndex, (int)JenkinsHash.ComputeHash(fullKey))
 {
 }
Ejemplo n.º 10
0
 internal StreamId(Memory <byte> fullKey, ushort keyIndex)
     : this(fullKey, keyIndex, (int)JenkinsHash.ComputeHash(fullKey.ToArray()))
 {
 }