コード例 #1
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
         ());
 }
コード例 #2
0
ファイル: SlotChange.cs プロジェクト: danfma/db4o-net
 public override void Write(ByteArrayBuffer writer)
 {
     if (SlotModified())
     {
         writer.WriteInt(_key);
         writer.WriteInt(_newSlot.Address());
         writer.WriteInt(_newSlot.Length());
     }
 }
コード例 #3
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());
		}
コード例 #4
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();
 }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: IdSlotMapping.cs プロジェクト: masroore/db4o
 public IdSlotMapping(int id, Slot slot) : this(id,
     slot.Address(), slot.Length())
 {
 }
コード例 #7
0
		public Slot ToNonBlockedLength(Slot slot)
		{
			return new Slot(slot.Address(), BlocksToBytes(slot.Length()));
		}
コード例 #8
0
		private void WriteSlot(ByteArrayBuffer buffer, Slot slot, bool writeZero)
		{
			if (writeZero || slot == null)
			{
				buffer.WriteInt(0);
				buffer.WriteInt(0);
				return;
			}
			buffer.WriteInt(slot.Address());
			buffer.WriteInt(slot.Length());
		}
コード例 #9
0
		private void ZeroFile(BlockAwareBin io, Slot slot)
		{
			if (io == null)
			{
				return;
			}
			byte[] zeroBytes = new byte[1024];
			int left = slot.Length();
			int offset = 0;
			while (left > zeroBytes.Length)
			{
				io.BlockWrite(slot.Address(), offset, zeroBytes, zeroBytes.Length);
				offset += zeroBytes.Length;
				left -= zeroBytes.Length;
			}
			if (left > 0)
			{
				io.BlockWrite(slot.Address(), offset, zeroBytes, left);
			}
		}
コード例 #10
0
ファイル: DTrace.cs プロジェクト: masroore/db4o
 public virtual void LogLength(long id, Slot slot)
 {
     if (enabled)
     {
         if (slot == null)
         {
             return;
         }
         LogLength(id, slot.Address(), slot.Length());
     }
 }
コード例 #11
0
ファイル: StatefulBuffer.cs プロジェクト: masroore/db4o
 public void UseSlot(Slot slot)
 {
     _address = slot.Address();
     _offset = 0;
     if (slot.Length() > _buffer.Length)
     {
         _buffer = new byte[slot.Length()];
     }
     _length = slot.Length();
 }
コード例 #12
0
ファイル: StatefulBuffer.cs プロジェクト: masroore/db4o
 public StatefulBuffer(Transaction trans, Slot
     slot) : this(trans, slot.Address(), slot.Length())
 {
 }
コード例 #13
0
ファイル: LocalObjectContainer.cs プロジェクト: erdincay/db4o
		public virtual StatefulBuffer ReadStatefulBufferBySlot(Transaction trans, int id, 
			Slot slot)
		{
			if (Slot.IsNull(slot))
			{
				return null;
			}
			if (DTrace.enabled)
			{
				DTrace.ReadSlot.LogLength(slot.Address(), slot.Length());
			}
			StatefulBuffer buffer = CreateStatefulBuffer(trans, slot.Address(), slot.Length()
				);
			buffer.SetID(id);
			buffer.ReadEncrypt(this, slot.Address());
			return buffer;
		}
コード例 #14
0
ファイル: LocalObjectContainer.cs プロジェクト: erdincay/db4o
		public virtual void OverwriteDeletedBlockedSlot(Slot slot)
		{
			OverwriteDeletedBytes(slot.Address(), _blockConverter.BlocksToBytes(slot.Length()
				));
		}
コード例 #15
0
ファイル: LocalObjectContainer.cs プロジェクト: erdincay/db4o
		public virtual ByteArrayBuffer ReadBufferBySlot(Slot slot)
		{
			if (Slot.IsNull(slot))
			{
				return null;
			}
			if (DTrace.enabled)
			{
				DTrace.ReadSlot.LogLength(slot.Address(), slot.Length());
			}
			ByteArrayBuffer buffer = new ByteArrayBuffer(slot.Length());
			buffer.ReadEncrypt(this, slot.Address());
			return buffer;
		}
コード例 #16
0
ファイル: LocalObjectContainer.cs プロジェクト: erdincay/db4o
		public virtual void Free(Slot slot)
		{
			if (slot.IsNull())
			{
				return;
			}
			// TODO: This should really be an IllegalArgumentException but old database files 
			//       with index-based FreespaceManagers appear to deliver zeroed slots.
			// throw new IllegalArgumentException();
			if (_freespaceManager == null)
			{
				// Can happen on early free before freespacemanager
				// is up, during conversion.
				return;
			}
			if (DTrace.enabled)
			{
				DTrace.FileFree.LogLength(slot.Address(), slot.Length());
			}
			_freespaceManager.Free(slot);
		}
コード例 #17
0
ファイル: LocalObjectContainer.cs プロジェクト: erdincay/db4o
		public virtual void WritePointer(int id, Slot slot)
		{
			if (DTrace.enabled)
			{
				DTrace.WritePointer.Log(id);
				DTrace.WritePointer.LogLength(slot);
			}
			_pointerIo.Seek(0);
			_pointerIo.WriteInt(slot.Address());
			_pointerIo.WriteInt(slot.Length());
			WriteBytes(_pointerIo, id, 0);
		}
コード例 #18
0
			// TODO Auto-generated method stub
			public override void Free(Slot slot)
			{
				_freedSlots.Add(slot.Address());
			}
コード例 #19
0
ファイル: DatabaseIdMapping.cs プロジェクト: masroore/db4o
 public override void MapId(int id, Slot slot)
 {
     _slotTree.Add(Trans(), new IdSlotMapping(id, slot.Address(), slot.Length()));
     if (_commitFrequency > 0)
     {
         _slotInsertCount++;
         if (_commitFrequency == _slotInsertCount)
         {
             _slotTree.Commit(Trans());
             _slotInsertCount = 0;
         }
     }
 }
コード例 #20
0
ファイル: SlotMapImpl.cs プロジェクト: masroore/db4o
 public virtual void Add(Slot slot)
 {
     _slots = ((TreeIntObject) Tree.Add(_slots, new TreeIntObject(slot.Address(), slot)
         ));
 }
コード例 #21
0
		public override void Free(Slot slot)
		{
			if (!IsStarted())
			{
				return;
			}
			if (IsDelegating())
			{
				_delegate.Free(slot);
				return;
			}
			try
			{
				BeginDelegation();
				if (DTrace.enabled)
				{
					DTrace.FreespacemanagerBtreeFree.LogLength(slot.Address(), slot.Length());
				}
				Slot[] remove = new Slot[2];
				Slot newFreeSlot = slot;
				BTreePointer pointer = SearchBTree(_slotsByAddress, slot, SearchTarget.Lowest);
				BTreePointer previousPointer = pointer != null ? pointer.Previous() : _slotsByAddress
					.LastPointer(Transaction());
				if (previousPointer != null)
				{
					Slot previousSlot = (Slot)previousPointer.Key();
					if (previousSlot.IsDirectlyPreceding(newFreeSlot))
					{
						remove[0] = previousSlot;
						newFreeSlot = previousSlot.Append(newFreeSlot);
					}
				}
				if (pointer != null)
				{
					Slot nextSlot = (Slot)pointer.Key();
					if (newFreeSlot.IsDirectlyPreceding(nextSlot))
					{
						remove[1] = nextSlot;
						newFreeSlot = newFreeSlot.Append(nextSlot);
					}
				}
				for (int i = 0; i < remove.Length; i++)
				{
					if (remove[i] != null)
					{
						RemoveSlot(remove[i]);
					}
				}
				if (!CanDiscard(newFreeSlot.Length()))
				{
					AddSlot(newFreeSlot);
				}
				SlotFreed(slot);
			}
			finally
			{
				EndDelegation();
			}
		}
コード例 #22
0
 public StatefulBuffer(Db4objects.Db4o.Internal.Transaction trans, Db4objects.Db4o.Internal.Slots.Slot
                       slot) : this(trans, slot.Address(), slot.Length())
 {
 }
コード例 #23
0
		private bool Overlap(Slot slot, Slot other)
		{
			Slot first = slot.Address() < other.Address() ? slot : other;
			Slot second = slot.Address() > other.Address() ? slot : other;
			return first.Address() + first.Length() >= second.Address();
		}
コード例 #24
0
ファイル: Pointer4.cs プロジェクト: azureskydiver/db4objects
 public virtual int Address()
 {
     return(_slot.Address());
 }
コード例 #25
0
		private void WriteToFile(Transaction trans, ByteArrayBuffer writer, Slot slot)
		{
			if (DTrace.enabled)
			{
				DTrace.PersistentbaseWrite.Log(GetID());
			}
			LocalObjectContainer container = (LocalObjectContainer)trans.Container();
			WriteThis(trans, writer);
			container.WriteEncrypt(writer, slot.Address(), 0);
			if (IsActive())
			{
				SetStateClean();
			}
		}
コード例 #26
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);
		}
コード例 #27
0
			public MappingTree(Slot slot, ConsistencyChecker.SlotSource source) : base(slot.Address
				(), new ConsistencyChecker.SlotWithSource(slot, source))
			{
			}