public static void AssertEmpty(Transaction transaction, BTree tree) { ExpectingVisitor visitor = new ExpectingVisitor(new object[0]); tree.TraverseKeys(transaction, visitor); visitor.AssertExpectations(); Assert.AreEqual(0, tree.Size(transaction)); }
/// <exception cref="System.Exception"></exception> private BTree CycleIntKeys(BTree btree) { AddKeys(btree); ExpectKeys(btree, _sortedKeys); btree.Commit(Trans()); ExpectKeys(btree, _sortedKeys); RemoveKeys(btree); ExpectKeys(btree, _keysOnRemoval); btree.Rollback(Trans()); ExpectKeys(btree, _sortedKeys); var id = btree.GetID(); Reopen(); btree = BTreeAssert.CreateIntKeyBTree(Container(), id, BtreeNodeSize); ExpectKeys(btree, _sortedKeys); RemoveKeys(btree); ExpectKeys(btree, _keysOnRemoval); btree.Commit(Trans()); ExpectKeys(btree, _keysOnRemoval); // remove all but 1 for (var i = 1; i < _keysOnRemoval.Length; i++) { btree.Remove(Trans(), _keysOnRemoval[i]); } ExpectKeys(btree, _one); btree.Commit(Trans()); ExpectKeys(btree, _one); btree.Remove(Trans(), 1); btree.Rollback(Trans()); ExpectKeys(btree, _one); btree.Remove(Trans(), 1); btree.Commit(Trans()); ExpectKeys(btree, _none); return btree; }
public override object Commit(Transaction trans, BTree btree, BTreeNode node) { if (_transaction == trans) { return GetObject(); } return this; }
public override object Rollback(Transaction trans, BTree btree) { if (_transaction == trans) { return RolledBack(btree); } return this; }
private void CreateBTreeIndex(ObjectContainerBase stream, int btreeID) { if (stream.IsClient) { return; } _btreeIndex = ((LocalObjectContainer)stream).CreateBTreeClassIndex(btreeID); _btreeIndex.SetRemoveListener(new _IVisitor4_61(this)); }
private void CreateBTrees(int addressID, int lengthID) { BTreeConfiguration config = new BTreeConfiguration(_idSystem, SlotChangeFactory.FreeSpace , 64, false); _slotsByAddress = new BTree(Transaction(), config, addressID, new AddressKeySlotHandler ()); _slotsByLength = new BTree(Transaction(), config, lengthID, new LengthKeySlotHandler ()); }
public BigSet(LocalObjectContainer db) { if (db == null) { return; } _transaction = db.Transaction; _bTree = BTreeManager().NewBTree(); }
public BTreeNode(BTree btree, int count, bool isLeaf, int parentID, int previousID , int nextID) { _btree = btree; _parentID = parentID; _previousID = previousID; _nextID = nextID; _count = count; _isLeaf = isLeaf; PrepareArrays(); }
public virtual void Read(IReadContext context) { int id = context.ReadInt(); if (_bTree != null) { AssertCurrentBTreeId(id); return; } _transaction = context.Transaction(); _bTree = BTreeManager().ProduceBTree(id); }
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; }
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; }
public static void AssertSingleElement(Transaction trans, BTree btree, object element ) { Assert.AreEqual(1, btree.Size(trans)); IBTreeRange result = btree.SearchRange(trans, element); ExpectingVisitor expectingVisitor = new ExpectingVisitor(new object[] { element } ); BTreeAssert.TraverseKeys(result, expectingVisitor); expectingVisitor.AssertExpectations(); expectingVisitor = new ExpectingVisitor(new object[] { element }); btree.TraverseKeys(trans, expectingVisitor); expectingVisitor.AssertExpectations(); }
private void Initialize() { int idToTimestampIndexId = _container.SystemData().IdToTimestampIndexId(); int timestampToIdIndexId = _container.SystemData().TimestampToIdIndexId(); _idToTimestamp = new BTree(_container.SystemTransaction(), idToTimestampIndexId, new CommitTimestampSupport.TimestampEntryById()); _timestampToId = new BTree(_container.SystemTransaction(), timestampToIdIndexId, new CommitTimestampSupport.IdEntryByTimestamp()); if (idToTimestampIndexId != _idToTimestamp.GetID()) { StoreBtreesIds(); } EventRegistryFactory.ForObjectContainer(_container).Committing += new System.EventHandler<Db4objects.Db4o.Events.CommitEventArgs> (new _IEventListener4_69(this).OnEvent); }
public virtual void Convert(LocalObjectContainer container, int classIndexId, BTree bTree) { Transaction trans = container.SystemTransaction(); ByteArrayBuffer reader = container.ReadBufferById(trans, classIndexId); if (reader == null) { return; } int entries = reader.ReadInt(); for (int i = 0; i < entries; i++) { bTree.Add(trans, reader.ReadInt()); } }
private void ExpectKeysSearch(BTree btree, int[] values) { int lastValue = int.MinValue; for (int i = 0; i < values.Length; i++) { if (values[i] != lastValue) { ExpectingVisitor expectingVisitor = ExpectingVisitor.CreateExpectingVisitor(values [i], IntArrays4.Occurences(values, values[i])); IBTreeRange range = FieldIndexKeySearch(Trans(), btree, values[i]); BTreeAssert.TraverseKeys(range, new _IVisitor4_62(expectingVisitor)); expectingVisitor.AssertExpectations(); lastValue = values[i]; } } }
private void ExpectKeysSearch(Transaction trans, BTree btree, int[] keys) { int lastValue = int.MinValue; for (int i = 0; i < keys.Length; i++) { if (keys[i] != lastValue) { ExpectingVisitor expectingVisitor = ExpectingVisitor.CreateExpectingVisitor(keys[ i], IntArrays4.Occurences(keys, keys[i])); IBTreeRange range = btree.SearchRange(trans, keys[i]); BTreeAssert.TraverseKeys(range, expectingVisitor); expectingVisitor.AssertExpectations(); lastValue = keys[i]; } } }
public override object Commit(Transaction trans, BTree btree, BTreeNode node) { Db4objects.Db4o.Internal.Btree.BTreeUpdate patch = (Db4objects.Db4o.Internal.Btree.BTreeUpdate )ForTransaction(trans); if (patch is BTreeCancelledRemoval) { object obj = patch.GetCommittedObject(); ApplyKeyChange(obj); } else { if (patch is BTreeRemove) { RemovedBy(trans, btree, node); patch.Committed(btree); return No4.Instance; } } return InternalCommit(trans, btree); }
private void Initialize() { var idToTimestampIndexId = _container.SystemData().IdToTimestampIndexId(); var timestampToIdIndexId = _container.SystemData().TimestampToIdIndexId(); if (_container.Config().IsReadOnly()) { if (idToTimestampIndexId == 0) { return; } } _idToTimestamp = new BTree(_container.SystemTransaction(), idToTimestampIndexId, new TimestampEntryById()); _timestampToId = new BTree(_container.SystemTransaction(), timestampToIdIndexId, new IdEntryByTimestamp()); if (idToTimestampIndexId != _idToTimestamp.GetID()) { StoreBtreesIds(); } EventRegistryFactory.ForObjectContainer(_container).Committing += new _IEventListener4_65(this).OnEvent; }
/// <exception cref="System.Exception"></exception> private BTree CycleIntKeys(BTree btree, int[] values) { for (int i = 0; i < values.Length; i++) { btree.Add(Trans(), values[i]); } ExpectKeysSearch(Trans(), btree, values); btree.Commit(Trans()); int id = btree.GetID(); Container().Commit(Trans()); Reopen(); btree = BTreeAssert.CreateIntKeyBTree(Container(), id, BtreeNodeSize); ExpectKeysSearch(Trans(), btree, values); for (int i = 0; i < values.Length; i++) { btree.Remove(Trans(), values[i]); } BTreeAssert.AssertEmpty(Trans(), btree); btree.Commit(Trans()); BTreeAssert.AssertEmpty(Trans(), btree); return btree; }
protected abstract void Committed(BTree btree);
public static int[] NewBTreeNodeSizedArray(BTree btree, int value) { return IntArrays4.Fill(new int[FillSize(btree)], value); }
internal BTreeNodeSearchResult(Transaction trans, ByteArrayBuffer nodeReader, BTree btree, BTreeNode node, int cursor, bool foundMatch) : this(trans, btree, PointerOrNull (trans, nodeReader, node, cursor), foundMatch) { }
public static void AssertKeys(Transaction transaction, BTree btree, int[] keys) { ExpectingVisitor visitor = ExpectingVisitor.CreateExpectingVisitor(keys); btree.TraverseKeys(transaction, visitor); visitor.AssertExpectations(); }
public static void DumpKeys(Transaction trans, BTree tree) { tree.TraverseKeys(trans, new _IVisitor4_37()); }
private void InitializeExisting(int persistentArrayId) { _persistentState = new PersistentIntegerArray(SlotChangeFactory.IdSystem, _transactionalIdSystem , persistentArrayId); _persistentState.Read(Transaction()); _bTree = new BTree(Transaction(), BTreeConfiguration(), BTreeId(), new BTreeIdSystem.IdSlotMappingHandler ()); }
public _IVisitor4_311(BTree _enclosing) { this._enclosing = _enclosing; }
protected override void AdjustSizeOnRemovalByOtherTransaction(BTree btree, BTreeNode node) { }
protected override void AdjustSizeOnRemovalByOtherTransaction(BTree btree, BTreeNode node) { // The size was reduced for this entry, let's change back. btree.SizeChanged(_transaction, node, +1); }
internal virtual void EnsureIsManaged(BTree tree) { RegisterBTreeInTransaction(tree); }
private Db4objects.Db4o.Internal.Btree.BTree BTreeForUpdate() { Db4objects.Db4o.Internal.Btree.BTree bTree = BTree(); BTreeManager().EnsureIsManaged(bTree); return(bTree); }
public virtual void Invalidate() { _bTree = null; }
internal BTreeNodeSearchResult(Transaction trans, ByteArrayBuffer nodeReader, BTree btree, Searcher searcher, BTreeNode node) : this(trans, btree, NextPointerIf(PointerOrNull (trans, nodeReader, node, searcher.Cursor()), searcher.IsGreater()), searcher.FoundMatch ()) { }
public _IVisitor4_486(BTree _enclosing, IDefragmentServices services) { this._enclosing = _enclosing; this.services = services; }
public BTreeNode(int id, BTree btree) { _btree = btree; SetID(id); SetStateDeactivated(); }
public _ISlotCopyHandler_481(BTree _enclosing) { this._enclosing = _enclosing; }
public BTreeIterator(Transaction trans, BTree bTree) { _transaction = trans; _bTree = bTree; }
private void InitializeNew() { _bTree = new BTree(Transaction(), BTreeConfiguration(), new BTreeIdSystem.IdSlotMappingHandler ()); int idGeneratorValue = _container.Handlers.LowestValidId() - 1; _persistentState = new PersistentIntegerArray(SlotChangeFactory.IdSystem, _transactionalIdSystem , new int[] { _bTree.GetID(), idGeneratorValue, 0 }); _persistentState.Write(Transaction()); _parentIdSystem.ChildId(_persistentState.GetID()); }
protected virtual object RolledBack(BTree btree) { btree.NotifyRemoveListener(new TransactionContext(_transaction, GetObject())); return(No4.Instance); }
/// <exception cref="System.Exception"></exception> public static void AssertAllSlotsFreed(LocalTransaction trans, BTree bTree, ICodeBlock block) { LocalObjectContainer container = (LocalObjectContainer)trans.Container(); ITransactionalIdSystem idSystem = trans.IdSystem(); IEnumerator allSlotIDs = bTree.AllNodeIds(trans.SystemTransaction()); Collection4 allSlots = new Collection4(); while (allSlotIDs.MoveNext()) { int slotID = ((int)allSlotIDs.Current); Slot slot = idSystem.CurrentSlot(slotID); allSlots.Add(slot); } Slot bTreeSlot = idSystem.CurrentSlot(bTree.GetID()); allSlots.Add(bTreeSlot); Collection4 freedSlots = new Collection4(); IFreespaceManager freespaceManager = container.FreespaceManager(); container.InstallDebugFreespaceManager(new FreespaceManagerForDebug(new _ISlotListener_99 (freedSlots))); block.Run(); container.InstallDebugFreespaceManager(freespaceManager); Assert.IsTrue(freedSlots.ContainsAll(allSlots.GetEnumerator())); }
protected override void Committed(BTree btree) { btree.NotifyRemoveListener(new TransactionContext(_transaction, GetObject())); }
public abstract object Rollback(Transaction trans, BTree btree);
public static int FillSize(BTree btree) { return btree.NodeSize() + 1; }
public _IProcedure4_609(BTree _enclosing) { this._enclosing = _enclosing; }
public abstract object Commit(Transaction trans, BTree btree, BTreeNode node);
protected virtual object RolledBack(BTree btree) { btree.NotifyRemoveListener(new TransactionContext(_transaction, GetObject())); return No4.Instance; }
protected abstract void AdjustSizeOnRemovalByOtherTransaction(BTree btree, BTreeNode node);
private void RegisterBTreeInTransaction(BTree tree) { AssertValidBTreeId(tree.GetID()); BTreesIn(_transaction)[tree.GetID()] = tree; }
protected override void Committed(BTree btree) { }