Esempio n. 1
0
 /// <summary>
 /// Search the key in current node only, if key exits, return the key, otherwise, possibleNode is next node's
 /// segment id where the key is possibly stored.
 /// </summary>
 /// <param name="target"></param>
 /// <returns></returns>
 public IKey SearchKey(IKey target, ref int pos)
 {
     //Debug.Assert(this.m_keyNums >= ((m_order-1) >> 2));
     pos = 0;
     while (pos < this.m_keyNums && target.CompareTo(this.m_keys[pos]) > 0)
     {
         pos++;
     }
     if (pos < this.m_keyNums && target.CompareTo(this.m_keys[pos]) == 0)
     {
         //found
         return(this.m_keys[pos]);
     }
     else
     {
         //not found
         return(null);
     }
 }
Esempio n. 2
0
        public bool ReplaceKeyDataWSuccessor(IKey oldKey, IKey successor, int pos)
        {
            Debug.Assert(pos < this.m_keys.Length);
            Debug.Assert(m_keys[pos].CompareTo(oldKey) == 0);
            Debug.Assert(oldKey.CompareTo(successor) < 0);

            m_keys[pos] = successor;

            this.m_dirty = true;

            return(true);
        }
Esempio n. 3
0
        public IValue Get(IKey key)
        {
            if (GetHelper(key))
            {
                List <TS_Offset>             offsets = index[key];
                long                         offset  = offsets.Last().offset;
                DataBlock <KeyType, ValType> db      = ReadDataBlock(offset);
                IKey                         ikey    = db.key;
                IValue                       value   = db.value;

                if (key.CompareTo(ikey) == 0)
                {
                    return(value);
                }
                else
                {
                    // collision?
                    // TODO: need to handle collision?
                    throw new InvalidDataException("Key mismatch (unhandled key collision)");
                }
            }
            return(null);
        }
Esempio n. 4
0
		/// <summary>
		/// Search the key in current node only, if key exits, return the key, otherwise, possibleNode is next node's 
		/// segment id where the key is possibly stored.
		/// </summary>
		/// <param name="target"></param>
		/// <returns></returns>
		public IKey SearchKey(IKey target, ref int pos)
		{
			//Debug.Assert(this.m_keyNums >= ((m_order-1) >> 2));
			pos = 0;
			while (pos < this.m_keyNums && target.CompareTo(this.m_keys[pos])>0)
				pos ++;
			if (pos < this.m_keyNums && target.CompareTo(this.m_keys[pos])==0)
			{
				//found
				return this.m_keys[pos];
			}
			else
			{
				//not found
				return null;
			}
		}
Esempio n. 5
0
		public bool ReplaceKeyDataWSuccessor(IKey oldKey, IKey successor, int pos)
		{
			Debug.Assert(pos < this.m_keys.Length);
			Debug.Assert(m_keys[pos].CompareTo(oldKey) == 0);
			Debug.Assert(oldKey.CompareTo(successor) < 0);

			m_keys[pos] = successor;

			this.m_dirty = true;

			return true;
		}