本文整理汇总了C#中Db4objects.Db4o.Internal.StatefulBuffer类的典型用法代码示例。如果您正苦于以下问题:C# StatefulBuffer类的具体用法?C# StatefulBuffer怎么用?C# StatefulBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StatefulBuffer类属于Db4objects.Db4o.Internal命名空间,在下文中一共展示了StatefulBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
/// <summary>generates a new Db4oDatabase object with a unique signature.</summary>
/// <remarks>generates a new Db4oDatabase object with a unique signature.</remarks>
public static Db4objects.Db4o.Ext.Db4oDatabase Generate()
{
StatefulBuffer writer = new StatefulBuffer(null, 300);
new LatinStringIO().Write(writer, SignatureGenerator.GenerateSignature());
return new Db4objects.Db4o.Ext.Db4oDatabase(writer.GetWrittenBytes(), Runtime.CurrentTimeMillis
());
}
示例2: WriteFixedPart
public override void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread
, bool shuttingDown, StatefulBuffer writer, int blockSize)
{
SystemData systemData = file.SystemData();
writer.Append(Signature);
writer.WriteByte(Version());
writer.WriteInt((int)TimeToWrite(_timerFileLock.OpenTime(), shuttingDown));
writer.WriteLong(TimeToWrite(_timerFileLock.OpenTime(), shuttingDown));
writer.WriteLong(TimeToWrite(Runtime.CurrentTimeMillis(), shuttingDown));
writer.WriteInt(blockSize);
writer.WriteInt(systemData.ClassCollectionID());
writer.WriteByte(systemData.IdSystemType());
writer.WriteInt(((FileHeaderVariablePart2)_variablePart).Address());
writer.WriteInt(((FileHeaderVariablePart2)_variablePart).Length());
writer.WriteInt(_transactionPointerAddress);
writer.Write();
if (shuttingDown)
{
WriteVariablePart(file, true);
}
else
{
file.SyncFiles();
}
if (startFileLockingThread)
{
file.ThreadPool().Start("db4o lock thread", _timerFileLock);
}
}
示例3: ApplySlotChanges
public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount
, Slot reservedSlot)
{
if (slotChangeCount > 0)
{
Slot transactionLogSlot = SlotLongEnoughForLog(slotChangeCount, reservedSlot) ? reservedSlot
: AllocateSlot(true, slotChangeCount);
StatefulBuffer buffer = new StatefulBuffer(_container.SystemTransaction(), transactionLogSlot
);
buffer.WriteInt(transactionLogSlot.Length());
buffer.WriteInt(slotChangeCount);
AppendSlotChanges(buffer, slotChangeTree);
buffer.Write();
IRunnable 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: AppendPayLoad
private void AppendPayLoad(StatefulBuffer target, Pointer4 pointer, ByteArrayBuffer
payLoad)
{
target.WriteInt(payLoad.Length());
target.WriteInt(pointer.Id());
target.WriteInt(pointer.Address());
target.Append(payLoad._buffer);
}
示例5: Test
public virtual void Test()
{
StatefulBuffer writer = new StatefulBuffer(null, 300);
string stringRepresentation = SignatureGenerator.GenerateSignature();
new LatinStringIO().Write(writer, stringRepresentation);
Signature signature = new Signature(writer.GetWrittenBytes());
Assert.AreEqual(stringRepresentation, signature.ToString());
}
示例6: GetWriter
public sealed override MsgD GetWriter(StatefulBuffer bytes)
{
MsgD message = GetWriterForLength(bytes.Transaction(), bytes.Length() + Const4.IntLength
);
message._payLoad.WriteInt(bytes.GetAddress());
message._payLoad.Append(bytes._buffer);
return message;
}
示例7: Marshall
public static StatefulBuffer Marshall(Transaction ta, object obj)
{
SerializedGraph serialized = Marshall(ta.Container(), obj);
StatefulBuffer buffer = new StatefulBuffer(ta, serialized.Length());
buffer.Append(serialized._bytes);
buffer.UseSlot(serialized._id, 0, serialized.Length());
return buffer;
}
示例8: ReadIndexEntryFromObjectSlot
/// <summary>This readIndexEntry method reads from the parent slot.</summary>
/// <remarks>This readIndexEntry method reads from the parent slot.</remarks>
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
public virtual object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer
buffer)
{
int payLoadOffSet = buffer.ReadInt();
int length = buffer.ReadInt();
if (payLoadOffSet == 0)
{
return null;
}
return buffer.ReadPayloadWriter(payLoadOffSet, length);
}
示例9: DeleteMembers
private void DeleteMembers(StatefulBuffer objectBytes)
{
ObjectHeader oh = new ObjectHeader(_clazz, objectBytes);
DeleteInfo info = (DeleteInfo)TreeInt.Find(_transaction._delete, _id);
if (info != null)
{
if (info._cascade > _cascade)
{
_cascade = info._cascade;
}
}
objectBytes.SetCascadeDeletes(_cascade);
DeleteContextImpl context = new DeleteContextImpl(objectBytes, oh, _clazz.ClassReflector
(), null);
_clazz.DeleteMembers(context, _typeInfo, true);
}
示例10: ReplyFromServer
public Msg ReplyFromServer()
{
StatefulBuffer bytes = null;
// readWriterByID may fail in certain cases, for instance if
// and object was deleted by another client
int id = _payLoad.ReadInt();
int lastCommitted = _payLoad.ReadInt();
lock (ContainerLock())
{
bytes = Container().ReadStatefulBufferById(Transaction(), id, lastCommitted == 1);
}
if (bytes == null)
{
bytes = new StatefulBuffer(Transaction(), 0, 0);
}
return Msg.ObjectToClient.GetWriter(bytes);
}
示例11: ReplyFromServer
public Msg ReplyFromServer()
{
int address = ReadInt();
int length = ReadInt();
lock (ContainerLock())
{
StatefulBuffer bytes = new StatefulBuffer(this.Transaction(), address, length);
try
{
Container().ReadBytes(bytes._buffer, address, length);
return GetWriter(bytes);
}
catch (Exception)
{
// TODO: not nicely handled on the client side yet
return Msg.Null;
}
}
}
示例12: CompleteInterruptedTransaction
public override void CompleteInterruptedTransaction(int transactionId1, int transactionId2
)
{
if (transactionId1 <= 0 || transactionId1 != transactionId2)
{
return;
}
StatefulBuffer bytes = new StatefulBuffer(_container.SystemTransaction(), transactionId1
, Const4.IntLength);
bytes.Read();
int length = bytes.ReadInt();
if (length > 0)
{
bytes = new StatefulBuffer(_container.SystemTransaction(), transactionId1, length
);
bytes.Read();
bytes.IncrementOffset(Const4.IntLength);
ReadWriteSlotChanges(bytes);
}
_container.WriteTransactionPointer(0);
FlushDatabaseFile();
}
示例13: RebuildIndexForWriter
protected virtual void RebuildIndexForWriter(LocalObjectContainer container, StatefulBuffer
buffer, int objectId)
{
ObjectHeader objectHeader = new ObjectHeader(container, buffer);
ObjectIdContextImpl context = new ObjectIdContextImpl(container.SystemTransaction
(), buffer, objectHeader, objectId);
ClassMetadata classMetadata = context.ClassMetadata();
if (classMetadata.IsStruct())
{
// We don't keep version information for structs.
return;
}
if (classMetadata.SeekToField(container.SystemTransaction(), buffer, versionFieldMetadata
) != HandlerVersion.Invalid)
{
long version = ((long)versionFieldMetadata.Read(context));
if (version != 0)
{
LocalTransaction t = (LocalTransaction)container.SystemTransaction();
t.CommitTimestampSupport().Put(container.SystemTransaction(), objectId, version);
}
}
}
示例14: DeletePrimitiveEmbedded
// FIXME: This code has not been called in any test case when the
// new ArrayMarshaller was written.
// Apparently it only frees slots.
// For now the code simply returns without freeing.
/// <param name="classPrimitive"></param>
public void DeletePrimitiveEmbedded(StatefulBuffer buffer, PrimitiveTypeMetadata
classPrimitive)
{
buffer.ReadInt();
//int address = a_bytes.readInt();
buffer.ReadInt();
}
示例15: ReadFrom
object IIndexableTypeHandler.ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer buffer)
{
return ReadFrom(buffer);
}