Exemplo n.º 1
0
 public DeleteContextImpl(StatefulBuffer buffer, ObjectHeader
     objectHeader, IReflectClass fieldClass, Config4Field fieldConfig) : base(buffer
         .Transaction(), buffer, objectHeader)
 {
     _fieldClass = fieldClass;
     _fieldConfig = fieldConfig;
 }
Exemplo n.º 2
0
 public override void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread
     , bool shuttingDown, StatefulBuffer writer, int blockSize)
 {
     var 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);
     }
 }
Exemplo n.º 3
0
 /// <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)
 {
     var payLoadOffSet = buffer.ReadInt();
     var length = buffer.ReadInt();
     if (payLoadOffSet == 0)
     {
         return null;
     }
     return buffer.ReadPayloadWriter(payLoadOffSet, length);
 }
 public override void CompleteInterruptedTransaction(int transactionId1, int transactionId2
     )
 {
     if (transactionId1 <= 0 || transactionId1 != transactionId2)
     {
         return;
     }
     var bytes = new StatefulBuffer(_container.SystemTransaction(), transactionId1
         , Const4.IntLength);
     bytes.Read();
     var 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();
 }
 protected virtual void RebuildIndexForWriter(LocalObjectContainer container, StatefulBuffer
     buffer, int objectId)
 {
     var objectHeader = new ObjectHeader(container, buffer);
     var context = new ObjectIdContextImpl(container.SystemTransaction
         (), buffer, objectHeader, objectId);
     var classMetadata = context.ClassMetadata();
     if (classMetadata.IsStruct())
     {
         // We don't keep version information for structs.
         return;
     }
     if (classMetadata.SeekToField(container.SystemTransaction(), buffer, versionFieldMetadata
         ) != HandlerVersion.Invalid)
     {
         var version = ((long) versionFieldMetadata.Read(context));
         if (version != 0)
         {
             var t = (LocalTransaction) container.SystemTransaction();
             t.CommitTimestampSupport().Put(container.SystemTransaction(), objectId, version);
         }
     }
 }
Exemplo n.º 6
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 public object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer statefulBuffer
     )
 {
     return ReadIndexEntry(statefulBuffer.Transaction().Context(), statefulBuffer);
 }
 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);
 }
Exemplo n.º 8
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 public override object Read(MarshallerFamily mf, StatefulBuffer writer, bool redirect
     )
 {
     return mf._primitive.ReadFloat(writer);
 }
Exemplo n.º 9
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 public override object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer
     buffer)
 {
     return buffer.Container().ReadWriterByAddress(buffer.Transaction(), buffer.ReadInt
         (), buffer.ReadInt());
 }
Exemplo n.º 10
0
 internal static void SlotEntryToZeroes(LocalObjectContainer file, int address)
 {
     var writer = new StatefulBuffer(file.SystemTransaction(), address, SlotLength
         ());
     for (var i = 0; i < IntsInSlot; i++)
     {
         writer.WriteInt(0);
     }
     writer.WriteEncrypt();
 }
Exemplo n.º 11
0
 public override void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread
     , bool shuttingDown, StatefulBuffer writer, int blockSize)
 {
     throw new InvalidOperationException();
 }
Exemplo n.º 12
0
 protected virtual void WriteTransactionPointer(Transaction systemTransaction, int
     transactionPointer, int address, int offset)
 {
     var bytes = new StatefulBuffer(systemTransaction, address, TransactionPointerLength
         );
     bytes.MoveForward(offset);
     bytes.WriteInt(transactionPointer);
     bytes.WriteInt(transactionPointer);
     // Dangerous write. 
     // On corruption transaction pointers will not be the same and nothing will happen.
     bytes.Write();
 }
Exemplo n.º 13
0
 // TODO: freespaceID should not be passed here, it should be taken from SystemData
 public abstract void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread
     , bool shuttingDown, StatefulBuffer writer, int blockSize);
Exemplo n.º 14
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 public object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer statefulBuffer
     )
 {
     return Read(mf, statefulBuffer, true);
 }
Exemplo n.º 15
0
 /// <param name="mf"></param>
 /// <param name="buffer"></param>
 /// <param name="redirect"></param>
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 public virtual object Read(MarshallerFamily mf, StatefulBuffer buffer, bool redirect
     )
 {
     return Read1(buffer);
 }
Exemplo n.º 16
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 public override object Read(MarshallerFamily mf, StatefulBuffer buffer, bool redirect
     )
 {
     return mf._primitive.ReadShort(buffer);
 }
Exemplo n.º 17
0
 // 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();
 }