public void TraverseValues(Transaction transaction, IVisitor4 userVisitor) { if (!Alive()) { return; } AssertHasIndex(); ObjectContainerBase stream = transaction.Container(); if (stream.IsClient) { Exceptions4.ThrowRuntimeException(Db4objects.Db4o.Internal.Messages.ClientServerUnsupported ); } lock (stream.Lock()) { IContext context = transaction.Context(); _index.TraverseKeys(transaction, new _IVisitor4_861(this, userVisitor, context)); } }
public virtual BTreeNodeSearchResult SearchLeaf(Transaction trans, object key, SearchTarget target) { return SearchLeaf(trans, _keyHandler.PrepareComparison(trans.Context(), key), target ); }
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; }
public virtual IBTreeRange SearchRange(Transaction trans, object key) { KeyCantBeNull(key); return SearchRange(trans, KeyHandler().PrepareComparison(trans.Context(), key)); }
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; }
public virtual void Add(Transaction trans, object key) { KeyCantBeNull(key); IPreparedComparison preparedComparison = _keyHandler.PrepareComparison(trans.Context (), key); Add(trans, preparedComparison, key); }
public override void ReadThis(Transaction trans, ByteArrayBuffer reader) { ReadNodeHeader(reader); PrepareArrays(); bool isInner = !_isLeaf; for (int i = 0; i < _count; i++) { _keys[i] = KeyHandler().ReadIndexEntry(trans.Context(), reader); if (isInner) { _children[i] = reader.ReadInt(); } } }
internal object Key(Transaction trans, ByteArrayBuffer reader, int index) { if (CanWrite()) { return InternalKey(trans, index); } if (reader == null) { reader = PrepareRead(trans); } if (CanWrite()) { return InternalKey(trans, index); } SeekKey(reader, index); return KeyHandler().ReadIndexEntry(trans.Context(), reader); }
private int CompareInReadMode(Transaction trans, IPreparedComparison preparedComparison , ByteArrayBuffer reader, int index) { SeekKey(reader, index); return -preparedComparison.CompareTo(KeyHandler().ReadIndexEntry(trans.Context(), reader)); }
public override void WriteThis(Transaction trans, ByteArrayBuffer buffer) { int count = 0; int startOffset = buffer._offset; IContext context = trans.Context(); buffer.IncrementOffset(CountLeafAnd3LinkLength); if (_isLeaf) { for (int i = 0; i < _count; i++) { object obj = InternalKey(trans, i); if (obj != No4.Instance) { count++; KeyHandler().WriteIndexEntry(context, buffer, obj); } } } else { for (int i = 0; i < _count; i++) { if (ChildCanSupplyFirstKey(i)) { Db4objects.Db4o.Internal.Btree.BTreeNode child = (Db4objects.Db4o.Internal.Btree.BTreeNode )_children[i]; object childKey = child.FirstKey(trans); if (childKey != No4.Instance) { count++; KeyHandler().WriteIndexEntry(context, buffer, childKey); buffer.WriteIDOf(trans, child); } } else { count++; KeyHandler().WriteIndexEntry(context, buffer, Key(i)); buffer.WriteIDOf(trans, _children[i]); } } } int endOffset = buffer._offset; buffer._offset = startOffset; buffer.WriteInt(count); buffer.WriteByte(_isLeaf ? (byte)1 : (byte)0); buffer.WriteInt(_parentID); buffer.WriteInt(_previousID); buffer.WriteInt(_nextID); buffer._offset = endOffset; }
public void TraverseValues(Transaction transaction, IVisitor4 userVisitor) { if (!Alive()) { return; } AssertHasIndex(); ObjectContainerBase stream = transaction.Container(); if (stream.IsClient) { Exceptions4.ThrowRuntimeException(Db4objects.Db4o.Internal.Messages.ClientServerUnsupported ); } lock (stream.Lock()) { IContext context = transaction.Context(); _index.TraverseKeys(transaction, new _IVisitor4_866(this, userVisitor, context)); } }