public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount , Slot reservedSlot) { if (slotChangeCount > 0) { var transactionLogSlot = SlotLongEnoughForLog(slotChangeCount, reservedSlot) ? reservedSlot : AllocateSlot(true, slotChangeCount); var buffer = new StatefulBuffer(_container.SystemTransaction(), transactionLogSlot ); buffer.WriteInt(transactionLogSlot.Length()); buffer.WriteInt(slotChangeCount); AppendSlotChanges(buffer, slotChangeTree); buffer.Write(); var commitHook = _container.CommitHook(); FlushDatabaseFile(); _container.WriteTransactionPointer(transactionLogSlot.Address()); FlushDatabaseFile(); if (WriteSlots(slotChangeTree)) { FlushDatabaseFile(); } _container.WriteTransactionPointer(0); commitHook.Run(); FlushDatabaseFile(); if (transactionLogSlot != reservedSlot) { FreeSlot(transactionLogSlot); } } FreeSlot(reservedSlot); }
// _key, _slot._address, _slot._length public override object Read(ByteArrayBuffer buffer) { var id = buffer.ReadInt(); var slot = new Slot (buffer.ReadInt(), buffer.ReadInt()); return new IdSlotTree(id, slot); }
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); }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> private DatabaseIdentityIDAndUUID ReadDatabaseIdentityIDAndUUID (ObjectContainerBase container, ClassMetadata classMetadata, Slot oldSlot, bool checkClass) { if (DTrace.enabled) { DTrace.RereadOldUuid.LogLength(oldSlot.Address(), oldSlot.Length()); } var reader = container.DecryptedBufferByAddress(oldSlot.Address(), oldSlot .Length()); if (checkClass) { var realClass = ClassMetadata.ReadClass(container, reader); if (realClass != classMetadata) { return null; } } if (classMetadata.SeekToField(container.Transaction, reader, this) == HandlerVersion .Invalid) { return null; } return new DatabaseIdentityIDAndUUID(reader.ReadInt(), reader.ReadLong ()); }
public void Apply(object idSlot) { Db4objects.Db4o.Internal.Slots.Slot slot = ((Db4objects.Db4o.Internal.Slots.Slot) ((Pair)idSlot).second); usage.value += slot.Length(); this._enclosing._slots.Add(slot); }
public virtual void SlotFreed(Slot slot) { if (_slotFreedCallback == null) { return; } _slotFreedCallback.Apply(slot); }
public virtual void TestAllocateSlot() { Slot slot = new Slot(1, 15); _nonBlocked.Free(slot); Slot allocatedSlot = _nonBlocked.AllocateSlot(8); int expectedAllocatedSlotLength = _blockConverter.BlockAlignedBytes(8); Slot expectedSlot = new Slot(1, expectedAllocatedSlotLength); Assert.AreEqual(expectedSlot, allocatedSlot); }
public override ByteArrayBuffer GetByteLoad() { var address = _payLoad.ReadInt(); var length = _payLoad.Length() - (Const4.IntLength); var slot = new Slot(address, length); _payLoad.RemoveFirstBytes(Const4.IntLength); _payLoad.UseSlot(slot); return _payLoad; }
// do nothing public override void Free(Slot slot) { int address = slot.Address(); if (address <= 0) { throw new ArgumentException(); } int length = slot.Length(); if (DTrace.enabled) { DTrace.FreespacemanagerRamFree.LogLength(address, length); } _finder._key = address; FreeSlotNode sizeNode; FreeSlotNode addressnode = (FreeSlotNode)Tree.FindSmaller(_freeByAddress, _finder ); if ((addressnode != null) && ((addressnode._key + addressnode._peer._key) == address )) { sizeNode = addressnode._peer; RemoveFromFreeBySize(sizeNode); sizeNode._key += length; FreeSlotNode secondAddressNode = (FreeSlotNode)Tree.FindGreaterOrEqual(_freeByAddress , _finder); if ((secondAddressNode != null) && (address + length == secondAddressNode._key)) { sizeNode._key += secondAddressNode._peer._key; RemoveFromBothTrees(secondAddressNode._peer); } sizeNode.RemoveChildren(); AddToFreeBySize(sizeNode); } else { addressnode = (FreeSlotNode)Tree.FindGreaterOrEqual(_freeByAddress, _finder); if ((addressnode != null) && (address + length == addressnode._key)) { sizeNode = addressnode._peer; RemoveFromBothTrees(sizeNode); sizeNode._key += length; addressnode._key = address; addressnode.RemoveChildren(); sizeNode.RemoveChildren(); _freeByAddress = Tree.Add(_freeByAddress, addressnode); AddToFreeBySize(sizeNode); } else { if (CanDiscard(length)) { return; } AddFreeSlotNodes(address, length); } } SlotFreed(slot); }
private bool HandledAsReAdd(Slot slot) { if (!Slot.IsNull(slot)) { return false; } _clazz.AddToIndex(_transaction, _id); return true; }
public sealed override ByteArrayBuffer GetByteLoad() { int address = _payLoad.ReadInt(); int length = _payLoad.Length() - (Const4.IntLength); Slot slot = new Slot(address, length); _payLoad.RemoveFirstBytes(Const4.IntLength); _payLoad.UseSlot(slot); return this._payLoad; }
public void UseSlot(Db4objects.Db4o.Internal.Slots.Slot slot) { _address = slot.Address(); _offset = 0; if (slot.Length() > _buffer.Length) { _buffer = new byte[slot.Length()]; } _length = slot.Length(); }
public virtual void TestIndexMarshalling() { ByteArrayBuffer reader = new ByteArrayBuffer(2 * Const4.IntLength); Slot original = new Slot(unchecked((int)(0xdb)), unchecked((int)(0x40))); StringHandler().WriteIndexEntry(Context(), reader, original); reader._offset = 0; Slot retrieved = (Slot)StringHandler().ReadIndexEntry(Context(), reader); Assert.AreEqual(original.Address(), retrieved.Address()); Assert.AreEqual(original.Length(), retrieved.Length()); }
public virtual void TestToNonBlockedLength() { int[] blocks = {0, 1, 8, 9}; int[] bytes = {0, 8, 64, 72}; for (var i = 0; i < blocks.Length; i++) { var blockedSlot = new Slot(0, blocks[i]); var byteSlot = new Slot(0, bytes[i]); Assert.AreEqual(byteSlot, blockConverter.ToNonBlockedLength(blockedSlot)); } }
public virtual void TestToBlockedLength() { int[] bytes = {0, 1, 2, 7, 8, 9, 16, 17, 799, 800, 801}; int[] blocks = {0, 1, 1, 1, 1, 2, 2, 3, 100, 100, 101}; for (var i = 0; i < bytes.Length; i++) { var byteSlot = new Slot(0, bytes[i]); var blockedSlot = new Slot(0, blocks[i]); Assert.AreEqual(blockedSlot, blockConverter.ToBlockedLength(byteSlot)); } }
public virtual void DelayedFree(Slot slot, bool freeToSystemFreeSpaceSystem) { if (freeToSystemFreeSpaceSystem) { _freeToSystemFreespaceSystem.Add(slot); } else { _freeToUserFreespaceSystem.Add(slot); } }
private void AssertAllocateSlot(int freeSlotSize, int requiredSlotSize, int expectedSlotSize ) { Slot slot = new Slot(1, freeSlotSize); _nonBlocked.Free(slot); Slot allocatedSlot = _nonBlocked.AllocateSlot(requiredSlotSize); int expectedAllocatedSlotLength = _blockConverter.BlockAlignedBytes(expectedSlotSize ); Slot expectedSlot = new Slot(1, expectedAllocatedSlotLength); Assert.AreEqual(expectedSlot, allocatedSlot); }
private void ReadThis() { SystemData systemData = _container.SystemData(); _slot = systemData.IdSystemSlot(); if (!Slot.IsNull(_slot)) { ByteArrayBuffer buffer = _container.ReadBufferBySlot(_slot); _childId = buffer.ReadInt(); _idGenerator.Read(buffer); _ids = (IdSlotTree)new TreeReader(buffer, new IdSlotTree(0, null)).Read(); } }
private void FreeSlot(Slot slot) { if (slot == null) { return; } if (_container.FreespaceManager() == null) { return; } _container.FreespaceManager().FreeSafeSlot(slot); }
protected override void Free(IFreespaceManager freespaceManager, Slot slot) { if (slot.IsNull()) { return; } if (_freed == null) { _freed = new Collection4(); } _freed.Add(slot); }
public virtual Tree Free(LocalObjectContainer file, Tree treeRoot, Slot slot) { file.Free(_slot.Address(), _slot.Length()); if (RemoveReferenceIsLast()) { if (treeRoot != null) { return treeRoot.RemoveNode(this); } } PointTo(slot); return treeRoot; }
private long ClassMetadataUsage() { Db4objects.Db4o.Internal.Slots.Slot classRepositorySlot = Slot(_db.ClassCollection ().GetID()); _slots.Add(classRepositorySlot); long usage = classRepositorySlot.Length(); IEnumerator classIdIter = _db.ClassCollection().Ids(); while (classIdIter.MoveNext()) { int curClassId = (((int)classIdIter.Current)); Db4objects.Db4o.Internal.Slots.Slot classSlot = Slot(curClassId); _slots.Add(classSlot); usage += classSlot.Length(); } return(usage); }
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); }
public SlotDetail(Slot slot) { this._slot = slot; }
public virtual void NotifyDeleted(IFreespaceManager freespaceManager) { if (DTrace.enabled) { DTrace.NotifySlotDeleted.Log(_key); } Operation(SlotChange.SlotChangeOperation.delete); FreePreviouslyModifiedSlot(freespaceManager); _newSlot = Slot.Zero; }
public virtual void NotifySlotCreated(Slot slot) { if (DTrace.enabled) { DTrace.NotifySlotCreated.Log(_key); DTrace.NotifySlotCreated.LogLength(slot); } Operation(SlotChange.SlotChangeOperation.create); _newSlot = slot; }
protected virtual void Free(IFreespaceManager freespaceManager, Slot slot) { if (slot.IsNull()) { return; } if (freespaceManager == null) { return; } freespaceManager.Free(slot); }
protected virtual void FreePreviouslyModifiedSlot(IFreespaceManager freespaceManager ) { if (Slot.IsNull(_newSlot)) { return; } Free(freespaceManager, _newSlot); _newSlot = null; }
public virtual void NotifySlotUpdated(IFreespaceManager freespaceManager, Slot slot ) { if (DTrace.enabled) { DTrace.NotifySlotUpdated.LogLength(_key, slot); } FreePreviouslyModifiedSlot(freespaceManager); _newSlot = slot; Operation(SlotChange.SlotChangeOperation.update); }
public override object Read(ByteArrayBuffer reader) { SlotChange change = new SlotChange(reader.ReadInt()); Slot newSlot = new Slot(reader.ReadInt(), reader.ReadInt()); change.NewSlot(newSlot); return change; }
public virtual void SlotFreed(Slot slot) { }
public virtual void Free(Slot slot) { _listener.OnFree(slot); }
public Pointer4(int id, Slot slot) { _id = id; _slot = slot; }
public StatefulBuffer(Db4objects.Db4o.Internal.Transaction trans, Db4objects.Db4o.Internal.Slots.Slot slot) : this(trans, slot.Address(), slot.Length()) { }
public abstract void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount , Slot reservedSlot);
private bool IsValid(Slot slot) { return !Slot.IsNull(slot); }
private void NewSlot(Slot slot) { _newSlot = slot; }