public virtual void TestNewIdOverflow() { if (!((IdSystemTestSuite.IIdSystemProvider)_fixture.Value).SupportsIdOverflow()) { return; } LocalObjectContainer container = (LocalObjectContainer)Container(); IIdSystem idSystem = ((IdSystemTestSuite.IIdSystemProvider)_fixture.Value).NewInstance (container); IList allFreeIds = AllocateAllAvailableIds(idSystem); AssertNoMoreIdAvailable(idSystem); IList subSetOfIds = new ArrayList(); int counter = 0; for (IEnumerator currentIdIter = allFreeIds.GetEnumerator(); currentIdIter.MoveNext ();) { int currentId = ((int)currentIdIter.Current); counter++; if (counter % 3 == 0) { subSetOfIds.Add(currentId); } } AssertFreeAndReallocate(idSystem, subSetOfIds); AssertFreeAndReallocate(idSystem, allFreeIds); }
private long IdSystemUsage() { IIdSystem idSystem = _db.IdSystem(); long usage = 0; while (idSystem is BTreeIdSystem) { IIdSystem parentIdSystem = ((IIdSystem)FieldValue(idSystem, "_parentIdSystem")); usage += BTreeUsage(_db.SystemTransaction(), parentIdSystem, (BTree)FieldValue(idSystem , "_bTree"), _slots); PersistentIntegerArray persistentState = (PersistentIntegerArray)FieldValue(idSystem , "_persistentState"); int persistentStateId = persistentState.GetID(); Db4objects.Db4o.Internal.Slots.Slot persistentStateSlot = parentIdSystem.CommittedSlot (persistentStateId); _slots.Add(persistentStateSlot); usage += persistentStateSlot.Length(); idSystem = parentIdSystem; } if (idSystem is InMemoryIdSystem) { Db4objects.Db4o.Internal.Slots.Slot idSystemSlot = ((Db4objects.Db4o.Internal.Slots.Slot )FieldValue(idSystem, "_slot")); usage += idSystemSlot.Length(); _slots.Add(idSystemSlot); } return(usage); }
private void MapIdSystem() { IIdSystem idSystem = _db.IdSystem(); if (idSystem is BTreeIdSystem) { ((BTreeIdSystem)idSystem).TraverseIds(new _IVisitor4_220(this)); } }
internal void FreePrefetchedIDs(IIdSystem idSystem) { if (_prefetchedIDs == null) { return; } idSystem.ReturnUnusedIds(_prefetchedIDs); _prefetchedIDs = null; }
private void MapIdSystem() { IIdSystem idSystem = _db.IdSystem(); if (!(idSystem is BTreeIdSystem)) { Sharpen.Runtime.Err.WriteLine("No btree id system found - not mapping ids."); return; } ((BTreeIdSystem)idSystem).TraverseIds(new _IVisitor4_127(this)); idSystem.TraverseOwnSlots(new _IProcedure4_138(this)); }
private IList AllocateAllAvailableIds(IIdSystem idSystem) { IList ids = new ArrayList(); int newId = 0; do { newId = idSystem.NewId(); ids.Add(newId); }while (newId < MaxValidId); return(ids); }
private static long BTreeUsage(Transaction transaction, IIdSystem idSystem, BTree btree, ISlotMap slotMap) { IEnumerator nodeIter = btree.AllNodeIds(transaction); Db4objects.Db4o.Internal.Slots.Slot btreeSlot = idSystem.CommittedSlot(btree.GetID ()); slotMap.Add(btreeSlot); long usage = btreeSlot.Length(); while (nodeIter.MoveNext()) { int curNodeId = ((int)nodeIter.Current); Db4objects.Db4o.Internal.Slots.Slot slot = idSystem.CommittedSlot(curNodeId); slotMap.Add(slot); usage += slot.Length(); } return(usage); }
private static long BTreeUsage(Transaction transaction, IIdSystem idSystem, BTree btree, ISlotMap slotMap) { var nodeIter = btree.AllNodeIds(transaction); var btreeSlot = idSystem.CommittedSlot(btree.GetID ()); slotMap.Add(btreeSlot); long usage = btreeSlot.Length(); while (nodeIter.MoveNext()) { var curNodeId = ((int)nodeIter.Current); var slot = idSystem.CommittedSlot(curNodeId); slotMap.Add(slot); usage += slot.Length(); } return(usage); }
private void AssertFreeAndReallocate(IIdSystem idSystem, IList ids) { // Boundary condition: Last ID. Produced a bug when implementing. if (!ids.Contains(MaxValidId)) { ids.Add(MaxValidId); } Assert.IsGreater(0, ids.Count); idSystem.ReturnUnusedIds(new _IVisitable_184(ids)); int freedCount = ids.Count; for (int i = 0; i < freedCount; i++) { int newId = idSystem.NewId(); Assert.IsTrue(ids.Contains(newId)); ids.Remove((object)newId); } Assert.IsTrue(ids.Count == 0); AssertNoMoreIdAvailable(idSystem); }
private IList CheckClassIndices() { IList invalidIds = new ArrayList(); IIdSystem idSystem = _db.IdSystem(); if (!(idSystem is BTreeIdSystem)) { return(invalidIds); } ClassMetadataIterator clazzIter = _db.ClassCollection().Iterator(); while (clazzIter.MoveNext()) { ClassMetadata clazz = clazzIter.CurrentClass(); if (!clazz.HasClassIndex()) { continue; } BTreeClassIndexStrategy index = (BTreeClassIndexStrategy)clazz.Index(); index.TraverseAll(_db.SystemTransaction(), new _IVisitor4_143(this, invalidIds, clazz )); } return(invalidIds); }
private IList AllocateAllAvailableIds(IIdSystem idSystem) { IList ids = new ArrayList(); int newId = 0; do { newId = idSystem.NewId(); ids.Add(newId); } while (newId < MaxValidId); return ids; }
protected virtual void CreateIdSystem() { _idSystem = StandardIdSystemFactory.NewInstance(this); }
public DelegatingIdSystem(LocalObjectContainer container) { _delegate = new InMemoryIdSystem(container); }
public _ICodeBlock_219(IIdSystem idSystem) { this.idSystem = idSystem; }
private void AssertNoMoreIdAvailable(IIdSystem idSystem) { Assert.Expect(typeof(Db4oFatalException), new _ICodeBlock_219(idSystem)); }
private static long BTreeUsage(Transaction transaction, IIdSystem idSystem, BTree btree, ISlotMap slotMap) { IEnumerator nodeIter = btree.AllNodeIds(transaction); Db4objects.Db4o.Internal.Slots.Slot btreeSlot = idSystem.CommittedSlot(btree.GetID ()); slotMap.Add(btreeSlot); long usage = btreeSlot.Length(); while (nodeIter.MoveNext()) { int curNodeId = ((int)nodeIter.Current); Db4objects.Db4o.Internal.Slots.Slot slot = idSystem.CommittedSlot(curNodeId); slotMap.Add(slot); usage += slot.Length(); } return usage; }
private static long BTreeUsage(Transaction transaction, IIdSystem idSystem, BTree btree, ISlotMap slotMap) { var nodeIter = btree.AllNodeIds(transaction); var btreeSlot = idSystem.CommittedSlot(btree.GetID ()); slotMap.Add(btreeSlot); long usage = btreeSlot.Length(); while (nodeIter.MoveNext()) { var curNodeId = ((int) nodeIter.Current); var slot = idSystem.CommittedSlot(curNodeId); slotMap.Add(slot); usage += slot.Length(); } return usage; }