Esempio n. 1
0
        private void WriteField(Value value, int type)
        {
            int offset = dataOffset + FIELD_HEADER_SIZE;

            dataBuffer[offset++] = (byte)value.Type;
            int len = value.Write(dataBuffer, offset) + 1;

            WriteFieldHeader(len, type);
            dataOffset += len;
        }
Esempio n. 2
0
        /// <summary>
        /// Generate unique server hash value from set name, key type and user defined key.
        /// The hash function is RIPEMD-160 (a 160 bit hash).
        /// </summary>
        /// <param name="setName">optional set name, enter null when set does not exist</param>
        /// <param name="key">record identifier, unique within set</param>
        /// <returns>unique server hash value</returns>
        /// <exception cref="AerospikeException">if digest computation fails</exception>
        public static byte[] ComputeDigest(string setName, Value key)
        {
            byte[] buffer = ThreadLocalData.GetBuffer();
            int    offset = ByteUtil.StringToUtf8(setName, buffer, 0);

            buffer[offset++] = (byte)key.Type;
            offset          += key.Write(buffer, offset);

            return(Hash.ComputeHash(buffer, offset));
        }
 private void WriteField(Value value, int type)
 {
     int offset = dataOffset + FIELD_HEADER_SIZE;
     dataBuffer[offset++] = (byte)value.Type;
     int len = value.Write(dataBuffer, offset) + 1;
     WriteFieldHeader(len, type);
     dataOffset += len;
 }
Esempio n. 4
0
        /// <summary>
        /// Generate unique server hash value from set name, key type and user defined key.  
        /// The hash function is RIPEMD-160 (a 160 bit hash).
        /// </summary>
        /// <param name="setName">optional set name, enter null when set does not exist</param>
        /// <param name="key">record identifier, unique within set</param>
        /// <returns>unique server hash value</returns>
        /// <exception cref="AerospikeException">if digest computation fails</exception>
        public static byte[] ComputeDigest(string setName, Value key)
        {
            byte[] buffer = ThreadLocalData.GetBuffer();
            int offset = ByteUtil.StringToUtf8(setName, buffer, 0);
            buffer[offset++] = (byte)key.Type;
            offset += key.Write(buffer, offset);

            return Hash.Algorithm.ComputeHash(buffer, 0, offset);
        }