public static bool Equals(Db4objects.Db4o.Internal.Btree.BTreePointer x, Db4objects.Db4o.Internal.Btree.BTreePointer
                           y)
 {
     if (x == null)
     {
         return(y == null);
     }
     return(x.Equals(y));
 }
 public virtual bool MoveNext()
 {
     if (ReachedEnd(_cursor))
     {
         _current = null;
         return false;
     }
     _current = _cursor;
     _cursor = _cursor.Next();
     return true;
 }
		public AbstractBTreeRangeIterator(BTreeRangeSingle range)
		{
			_range = range;
			BTreePointer first = range.First();
			if (first != null)
			{
				// we clone here, because we are calling unsafeNext() on BTreePointer
				// _cursor is our private copy, we modify it and never pass it out.
				_cursor = first.ShallowClone();
			}
		}
 private bool ReachedEnd(BTreePointer cursor)
 {
     if (cursor == null)
     {
         return true;
     }
     if (_range.End() == null)
     {
         return false;
     }
     return _range.End().Equals(cursor);
 }
示例#5
0
		public BTreeRangeSingle(Db4objects.Db4o.Internal.Transaction transaction, BTree btree
			, BTreePointer first, BTreePointer end)
		{
			if (transaction == null || btree == null)
			{
				throw new ArgumentNullException();
			}
			_transaction = transaction;
			_btree = btree;
			_first = first;
			_end = end;
		}
 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()));
 }
		internal BTreeNodeSearchResult(Transaction transaction, BTree btree, BTreePointer
			 pointer, bool foundMatch)
		{
			if (null == transaction || null == btree)
			{
				throw new ArgumentNullException();
			}
			_transaction = transaction;
			_btree = btree;
			_pointer = pointer;
			_foundMatch = foundMatch;
		}
		private static BTreePointer NextPointerIf(BTreePointer pointer, bool condition)
		{
			if (null == pointer)
			{
				return null;
			}
			if (condition)
			{
				return pointer.Next();
			}
			return pointer;
		}
示例#9
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();
			}
		}
示例#10
0
 public static BTreePointer Min(BTreePointer
     x, BTreePointer y)
 {
     if (x == null)
     {
         return y;
     }
     if (y == null)
     {
         return x;
     }
     if (x.CompareTo(y) < 0)
     {
         return x;
     }
     return y;
 }
示例#11
0
		public virtual bool MoveNext()
		{
			if (_beyondEnd)
			{
				return false;
			}
			if (BeforeFirst())
			{
				_currentPointer = _bTree.FirstPointer(_transaction);
			}
			else
			{
				_currentPointer = _currentPointer.Next();
			}
			_beyondEnd = (_currentPointer == null);
			return !_beyondEnd;
		}
 public static Db4objects.Db4o.Internal.Btree.BTreePointer Min(Db4objects.Db4o.Internal.Btree.BTreePointer
                                                               x, Db4objects.Db4o.Internal.Btree.BTreePointer y)
 {
     if (x == null)
     {
         return(y);
     }
     if (y == null)
     {
         return(x);
     }
     if (x.CompareTo(y) < 0)
     {
         return(x);
     }
     return(y);
 }
 public override bool Equals(object obj)
 {
     if (this == obj)
     {
         return(true);
     }
     if (!(obj is Db4objects.Db4o.Internal.Btree.BTreePointer))
     {
         return(false);
     }
     Db4objects.Db4o.Internal.Btree.BTreePointer other = (Db4objects.Db4o.Internal.Btree.BTreePointer
                                                          )obj;
     if (_index != other._index)
     {
         return(false);
     }
     return(_node.Equals(other._node));
 }
		public virtual bool MoveNext()
		{
			if (ReachedEnd())
			{
				_current = null;
				return false;
			}
			if (_current == null)
			{
				_current = _cursor.ShallowClone();
			}
			else
			{
				_cursor.CopyTo(_current);
			}
			_cursor = _cursor.UnsafeFastNext();
			return true;
		}
示例#15
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);
        }
示例#16
0
        private BTreePointer FirstBTreePointer()
        {
            // We don't want nulls included so we have to search for null and use the resulting pointer if we find one.
            IIndexable4 keyHandler = Btree().KeyHandler();

            if (keyHandler is ICanExcludeNullInQueries)
            {
                ICanExcludeNullInQueries canExcludeNullInQueries = (ICanExcludeNullInQueries)keyHandler;
                if (canExcludeNullInQueries.ExcludeNull())
                {
                    BTreeNodeSearchResult searchLeaf = Btree().SearchLeafByObject(Transaction(), null
                                                                                  , SearchTarget.Highest);
                    BTreePointer pointer = searchLeaf.FirstValidPointer();
                    if (pointer != null)
                    {
                        return(pointer);
                    }
                }
            }
            return(Btree().FirstPointer(Transaction()));
        }
示例#17
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);
        }
示例#18
0
 public virtual BTreeRangeSingle NewBTreeRangeSingle
     (BTreePointer first, BTreePointer end)
 {
     return new BTreeRangeSingle(Transaction(), _btree,
         first, end);
 }
示例#19
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());
 }
示例#20
0
		public virtual Db4objects.Db4o.Internal.Btree.BTreeRangeSingle NewBTreeRangeSingle
			(BTreePointer first, BTreePointer end)
		{
			return new Db4objects.Db4o.Internal.Btree.BTreeRangeSingle(Transaction(), _btree, 
				first, end);
		}
示例#21
0
 public static bool Equals(BTreePointer x, BTreePointer
     y)
 {
     if (x == null)
     {
         return y == null;
     }
     return x.Equals(y);
 }
示例#22
0
		protected virtual void AssertPointerKey(int key, BTreePointer pointer)
		{
			Assert.AreEqual(key, pointer.Key());
		}
示例#23
0
 public virtual Db4objects.Db4o.Internal.Btree.BTreeRangeSingle NewBTreeRangeSingle
     (BTreePointer first, BTreePointer end)
 {
     return(new Db4objects.Db4o.Internal.Btree.BTreeRangeSingle(Transaction(), _btree,
                                                                first, end));
 }
示例#24
0
 public static bool LessThan(BTreePointer x, BTreePointer
                             y)
 {
     return(Min(x, y) == x && !Equals(x, y
                                      ));
 }
示例#25
0
 public void CopyTo(Db4objects.Db4o.Internal.Btree.BTreePointer target)
 {
     target._node       = _node;
     target._index      = _index;
     target._nodeReader = _nodeReader;
 }
示例#26
0
 public virtual BTreeRangeSingle NewBTreeRangeSingle
     (BTreePointer first, BTreePointer end)
 {
     return(new BTreeRangeSingle(Transaction(), _btree,
                                 first, end));
 }
示例#27
0
 public AbstractBTreeRangeIterator(BTreeRangeSingle range)
 {
     _range = range;
     _cursor = range.First();
 }
示例#28
0
 public virtual bool Adjacent(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle range
                              )
 {
     return(BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end,
                                                                           _first));
 }
示例#29
0
 private bool FirstOverlaps(BTreeRangeSingle x, BTreeRangeSingle
                            y)
 {
     return(BTreePointer.LessThan(y._first, x._end) && BTreePointer.LessThan(x._first,
                                                                             y._end));
 }
示例#30
0
 public virtual bool IsEmpty()
 {
     return(BTreePointer.Equals(_first, _end));
 }
示例#31
0
 public AbstractBTreeRangeIterator(BTreeRangeSingle range)
 {
     _range  = range;
     _cursor = range.First();
 }
 public static bool LessThan(Db4objects.Db4o.Internal.Btree.BTreePointer x, Db4objects.Db4o.Internal.Btree.BTreePointer
                             y)
 {
     return(Db4objects.Db4o.Internal.Btree.BTreePointer.Min(x, y) == x && !Equals(x, y
                                                                                  ));
 }
 public virtual void Reset()
 {
     _cursor = _range.First();
 }
示例#34
0
 public virtual void Reset()
 {
     _cursor = _range.First();
 }
示例#35
0
 public static bool LessThan(BTreePointer x, BTreePointer
     y)
 {
     return Min(x, y) == x && !Equals(x, y
         );
 }
示例#36
0
 public virtual bool Adjacent(BTreeRangeSingle range
                              )
 {
     return(BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end,
                                                                           _first));
 }
示例#37
0
 private bool FirstOverlaps(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle x, Db4objects.Db4o.Internal.Btree.BTreeRangeSingle
                            y)
 {
     return(BTreePointer.LessThan(y._first, x._end) && BTreePointer.LessThan(x._first,
                                                                             y._end));
 }