Esempio n. 1
0
        }  // end addTimeStamp()

        /// <summary>
        /// Compute the hash of the key in the buffer.  Use the Murmurhash3
        /// algorithm to compute the hash.  If not all of the values have been
        /// added to the key (i.e. if the buffer is not full), then throw an
        /// exception.
        /// </summary>
        public void computHashes()
        {
            // Check all the values for the key have been added
            if (this.current_size != this.buffer_size)
            {
                throw new KineticaException("The RecordKey buffer is not full; check that all the relevant values have been added.");
            }

            // Hash the value
            MurMurHash3.LongPair murmur = new MurMurHash3.LongPair();
            MurMurHash3.murmurhash3_x64_128(this.buffer, 0, (uint)this.buffer_size, 10, out murmur);

            // Save the hash value
            this.routingHash = murmur.val1;
            this.hash_code   = (int)(this.routingHash ^ ((this.routingHash >> 32) & 0x0000ffffL));
        }  // end computHashes
Esempio n. 2
0
        }  // end addDouble

        /// <summary>
        /// Add a string to the buffer.  Hash the string value and add it
        /// as a long internally.
        /// </summary>
        /// <param name="value">The string value to be added.  Can be null.</param>
        public void addString(string value)
        {
            // Handle nulls
            if (value == null)
            {
                this.addLong(0L);
                return;
            }

            // Hash the value
            MurMurHash3.LongPair murmur   = new MurMurHash3.LongPair();
            System.Text.Encoding encoding = new System.Text.UTF8Encoding();
            byte[] input = encoding.GetBytes(value);
            MurMurHash3.murmurhash3_x64_128(input, 0, (uint)input.Length, 10, out murmur);

            // Add the hashed value to the buffer
            this.addLong(murmur.val1);
        }  // end addString