本文整理汇总了C#中Db4objects.Db4o.Internal.Slots.Slot类的典型用法代码示例。如果您正苦于以下问题:C# Slot类的具体用法?C# Slot怎么用?C# Slot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Slot类属于Db4objects.Db4o.Internal.Slots命名空间,在下文中一共展示了Slot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
// _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);
}
示例2: DatabaseIdentityIDAndUUID
/// <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
());
}
示例3: ApplySlotChanges
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);
}
示例4: SlotFreed
public virtual void SlotFreed(Slot slot)
{
if (_slotFreedCallback == null)
{
return;
}
_slotFreedCallback.Apply(slot);
}
示例5: GetByteLoad
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;
}
示例6: GetByteLoad
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;
}
示例7: HandledAsReAdd
private bool HandledAsReAdd(Slot slot)
{
if (!Slot.IsNull(slot))
{
return false;
}
_clazz.AddToIndex(_transaction, _id);
return true;
}
示例8: TestAllocateSlot
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);
}
示例9: Free
// 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: TestIndexMarshalling
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());
}
示例11: DelayedFree
public virtual void DelayedFree(Slot slot, bool freeToSystemFreeSpaceSystem)
{
if (freeToSystemFreeSpaceSystem)
{
_freeToSystemFreespaceSystem.Add(slot);
}
else
{
_freeToUserFreespaceSystem.Add(slot);
}
}
示例12: AssertAllocateSlot
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);
}
示例13: TestToNonBlockedLength
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));
}
}
示例14: TestToBlockedLength
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));
}
}
示例15: FreeSlot
private void FreeSlot(Slot slot)
{
if (slot == null)
{
return;
}
if (_container.FreespaceManager() == null)
{
return;
}
_container.FreespaceManager().FreeSafeSlot(slot);
}