コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: IdSlotTree.cs プロジェクト: masroore/db4o
 // _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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: UUIDFieldMetadata.cs プロジェクト: masroore/db4o
 /// <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
         ());
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 public virtual void SlotFreed(Slot slot)
 {
     if (_slotFreedCallback == null)
     {
         return;
     }
     _slotFreedCallback.Apply(slot);
 }
コード例 #7
0
		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);
		}
コード例 #8
0
ファイル: MReadSlot.cs プロジェクト: masroore/db4o
 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;
 }
コード例 #9
0
		// 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);
		}
コード例 #10
0
		private bool HandledAsReAdd(Slot slot)
		{
			if (!Slot.IsNull(slot))
			{
				return false;
			}
			_clazz.AddToIndex(_transaction, _id);
			return true;
		}
コード例 #11
0
ファイル: MReadSlot.cs プロジェクト: bvangrinsven/db4o-net
		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;
		}
コード例 #12
0
 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();
 }
コード例 #13
0
		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());
		}
コード例 #14
0
 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));
     }
 }
コード例 #15
0
 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));
     }
 }
コード例 #16
0
ファイル: FreespaceCommitter.cs プロジェクト: masroore/db4o
 public virtual void DelayedFree(Slot slot, bool freeToSystemFreeSpaceSystem)
 {
     if (freeToSystemFreeSpaceSystem)
     {
         _freeToSystemFreespaceSystem.Add(slot);
     }
     else
     {
         _freeToUserFreespaceSystem.Add(slot);
     }
 }
コード例 #17
0
		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);
		}
コード例 #18
0
ファイル: InMemoryIdSystem.cs プロジェクト: superyfwy/db4o
		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();
			}
		}
コード例 #19
0
 private void FreeSlot(Slot slot)
 {
     if (slot == null)
     {
         return;
     }
     if (_container.FreespaceManager() == null)
     {
         return;
     }
     _container.FreespaceManager().FreeSafeSlot(slot);
 }
コード例 #20
0
		protected override void Free(IFreespaceManager freespaceManager, Slot slot)
		{
			if (slot.IsNull())
			{
				return;
			}
			if (_freed == null)
			{
				_freed = new Collection4();
			}
			_freed.Add(slot);
		}
コード例 #21
0
ファイル: ReferencedSlot.cs プロジェクト: masroore/db4o
 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;
 }
コード例 #22
0
        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);
        }
コード例 #23
0
        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);
        }
コード例 #24
0
ファイル: SlotDetail.cs プロジェクト: erdincay/db4o
		public SlotDetail(Slot slot)
		{
			this._slot = slot;
		}
コード例 #25
0
ファイル: SlotChange.cs プロジェクト: Galigator/db4o
		public virtual void NotifyDeleted(IFreespaceManager freespaceManager)
		{
			if (DTrace.enabled)
			{
				DTrace.NotifySlotDeleted.Log(_key);
			}
			Operation(SlotChange.SlotChangeOperation.delete);
			FreePreviouslyModifiedSlot(freespaceManager);
			_newSlot = Slot.Zero;
		}
コード例 #26
0
ファイル: SlotChange.cs プロジェクト: Galigator/db4o
		public virtual void NotifySlotCreated(Slot slot)
		{
			if (DTrace.enabled)
			{
				DTrace.NotifySlotCreated.Log(_key);
				DTrace.NotifySlotCreated.LogLength(slot);
			}
			Operation(SlotChange.SlotChangeOperation.create);
			_newSlot = slot;
		}
コード例 #27
0
ファイル: SlotChange.cs プロジェクト: Galigator/db4o
		protected virtual void Free(IFreespaceManager freespaceManager, Slot slot)
		{
			if (slot.IsNull())
			{
				return;
			}
			if (freespaceManager == null)
			{
				return;
			}
			freespaceManager.Free(slot);
		}
コード例 #28
0
ファイル: SlotChange.cs プロジェクト: Galigator/db4o
		protected virtual void FreePreviouslyModifiedSlot(IFreespaceManager freespaceManager
			)
		{
			if (Slot.IsNull(_newSlot))
			{
				return;
			}
			Free(freespaceManager, _newSlot);
			_newSlot = null;
		}
コード例 #29
0
ファイル: SlotChange.cs プロジェクト: Galigator/db4o
		public virtual void NotifySlotUpdated(IFreespaceManager freespaceManager, Slot slot
			)
		{
			if (DTrace.enabled)
			{
				DTrace.NotifySlotUpdated.LogLength(_key, slot);
			}
			FreePreviouslyModifiedSlot(freespaceManager);
			_newSlot = slot;
			Operation(SlotChange.SlotChangeOperation.update);
		}
コード例 #30
0
ファイル: SlotChange.cs プロジェクト: Galigator/db4o
		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;
		}
コード例 #31
0
		public virtual void SlotFreed(Slot slot)
		{
		}
コード例 #32
0
		public virtual void Free(Slot slot)
		{
			_listener.OnFree(slot);
		}
コード例 #33
0
 public Pointer4(int id, Slot slot)
 {
     _id   = id;
     _slot = slot;
 }
コード例 #34
0
 public StatefulBuffer(Db4objects.Db4o.Internal.Transaction trans, Db4objects.Db4o.Internal.Slots.Slot
                       slot) : this(trans, slot.Address(), slot.Length())
 {
 }
コード例 #35
0
		public abstract void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount
			, Slot reservedSlot);
コード例 #36
0
ファイル: IdSystemTestSuite.cs プロジェクト: Galigator/db4o
			private bool IsValid(Slot slot)
			{
				return !Slot.IsNull(slot);
			}
コード例 #37
0
ファイル: SlotChange.cs プロジェクト: Galigator/db4o
		private void NewSlot(Slot slot)
		{
			_newSlot = slot;
		}