Esempio n. 1
0
        public virtual object Search(Transaction trans, object key)
        {
            BTreePointer bTreePointer = SearchPointer(trans, key);

            if (bTreePointer != null)
            {
                return(bTreePointer.Key());
            }
            return(null);
        }
 public int CompareTo(Db4objects.Db4o.Internal.Btree.BTreePointer y)
 {
     if (null == y)
     {
         throw new ArgumentNullException();
     }
     if (Btree() != y.Btree())
     {
         throw new ArgumentException();
     }
     return(Btree().CompareKeys(_transaction.Context(), Key(), y.Key()));
 }
Esempio n. 3
0
		private void AssertReadModePointerIteration(int[] expectedKeys, BTreePointer pointer
			)
		{
			object[] expected = IntArrays4.ToObjectArray(expectedKeys);
			for (int i = 0; i < expected.Length; i++)
			{
				Assert.IsNotNull(pointer, "Expected '" + expected[i] + "'");
				Assert.AreNotSame(_btree.Root(), pointer.Node());
				AssertInReadModeOrCached(pointer.Node());
				Assert.AreEqual(expected[i], pointer.Key());
				AssertInReadModeOrCached(pointer.Node());
				pointer = pointer.Next();
			}
		}
Esempio n. 4
0
        public virtual object Remove(Transaction trans, object key)
        {
            BTreePointer bTreePointer = SearchPointer(trans, key);

            if (bTreePointer == null)
            {
                return(null);
            }
            object result = bTreePointer.Key();

            Enlist(trans);
            IPreparedComparison preparedComparison = KeyHandler().PrepareComparison(trans.Context
                                                                                        (), key);
            BTreeNode node = bTreePointer.Node();

            node.Remove(trans, preparedComparison, key, bTreePointer.Index());
            ConvertCacheEvictedNodesToReadMode();
            return(result);
        }
Esempio n. 5
0
        public virtual BTreePointer SearchPointer(Transaction trans, object key)
        {
            EnsureActive(trans);
            KeyCantBeNull(key);
            IPreparedComparison preparedComparison = KeyHandler().PrepareComparison(trans.Context
                                                                                        (), key);
            BTreeNodeSearchResult start = SearchLeaf(trans, preparedComparison, SearchTarget.
                                                     Lowest);
            BTreePointer bTreePointer = start.FirstValidPointer();

            if (bTreePointer == null)
            {
                ConvertCacheEvictedNodesToReadMode();
                return(null);
            }
            object found = bTreePointer.Key();

            ConvertCacheEvictedNodesToReadMode();
            if (preparedComparison.CompareTo(found) == 0)
            {
                return(bTreePointer);
            }
            return(null);
        }
Esempio n. 6
0
		protected virtual void AssertPointerKey(int key, BTreePointer pointer)
		{
			Assert.AreEqual(key, pointer.Key());
		}
Esempio n. 7
0
 public int CompareTo(BTreePointer y)
 {
     if (null == y)
     {
         throw new ArgumentNullException();
     }
     if (Btree() != y.Btree())
     {
         throw new ArgumentException();
     }
     return Btree().CompareKeys(_transaction.Context(), Key(), y.Key());
 }