Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo 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);
     }
 }
Ejemplo n.º 3
0
        public virtual StatefulBuffer PayLoad()
        {
            StatefulBuffer writer = new StatefulBuffer(Transaction(), Const4.MessageLength);

            writer.WriteInt(_msgID);
            return(writer);
        }
Ejemplo n.º 4
0
        public void ProcessAtServer()
        {
            IServerMessageDispatcher dispatcher = (IServerMessageDispatcher)MessageDispatcher
                                                      ();
            int         count = ReadInt();
            Transaction ta    = Transaction();

            for (int i = 0; i < count; i++)
            {
                StatefulBuffer writer        = _payLoad.ReadStatefulBuffer();
                int            messageId     = writer.ReadInt();
                Msg            message       = Msg.GetMessage(messageId);
                Msg            clonedMessage = message.PublicClone();
                clonedMessage.SetMessageDispatcher(MessageDispatcher());
                clonedMessage.SetTransaction(ta);
                if (clonedMessage is MsgD)
                {
                    MsgD msgd = (MsgD)clonedMessage;
                    msgd.PayLoad(writer);
                    if (msgd.PayLoad() != null)
                    {
                        msgd.PayLoad().IncrementOffset(Const4.IntLength);
                        Transaction t = CheckParentTransaction(ta, msgd.PayLoad());
                        msgd.SetTransaction(t);
                        dispatcher.ProcessMessage(msgd);
                    }
                }
                else
                {
                    dispatcher.ProcessMessage(clonedMessage);
                }
            }
        }
Ejemplo n.º 5
0
 public DeleteContextImpl(StatefulBuffer buffer, ObjectHeader
     objectHeader, IReflectClass fieldClass, Config4Field fieldConfig) : base(buffer
         .Transaction(), buffer, objectHeader)
 {
     _fieldClass = fieldClass;
     _fieldConfig = fieldConfig;
 }
Ejemplo n.º 6
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();
 }
Ejemplo n.º 7
0
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
                                     entry)
 {
     if (entry == null)
     {
         writer.WriteInt(0);
         writer.WriteInt(0);
         return;
     }
     if (entry is StatefulBuffer)
     {
         StatefulBuffer entryAsWriter = (StatefulBuffer)entry;
         writer.WriteInt(entryAsWriter.GetAddress());
         writer.WriteInt(entryAsWriter.Length());
         return;
     }
     if (entry is Slot)
     {
         Slot s = (Slot)entry;
         writer.WriteInt(s.Address());
         writer.WriteInt(s.Length());
         return;
     }
     throw new ArgumentException();
 }
Ejemplo n.º 8
0
 public Msg ReplyFromServer()
 {
     try
     {
         lock (ContainerLock())
         {
             IReflectClass claxx = SystemTransaction().Reflector().ForName(ReadString());
             if (claxx != null)
             {
                 ClassMetadata classMetadata = Container().ProduceClassMetadata(claxx);
                 if (classMetadata != null)
                 {
                     Container().CheckStillToSet();
                     StatefulBuffer returnBytes = Container().ReadStatefulBufferById(SystemTransaction
                                                                                         (), classMetadata.GetID());
                     MsgD createdClass = Msg.ObjectToClient.GetWriter(returnBytes);
                     return(createdClass);
                 }
             }
         }
     }
     catch (Db4oException)
     {
     }
     // TODO: send the exception to the client
     return(Msg.Failed);
 }
Ejemplo n.º 9
0
        private void DebugCheckBuffer(ByteArrayBuffer buffer, Db4objects.Db4o.Internal.Freespace.FreeSlotNode
                                      node)
        {
            if (!(buffer is StatefulBuffer))
            {
                return;
            }
            Transaction trans = ((StatefulBuffer)buffer).Transaction();

            if (!(trans.Container() is IoAdaptedObjectContainer))
            {
                return;
            }
            StatefulBuffer checker = trans.Container().CreateStatefulBuffer(trans, node._peer
                                                                            ._key, node._key);

            checker.Read();
            for (int i = 0; i < node._key; i++)
            {
                if (checker.ReadByte() != (byte)'X')
                {
                    Sharpen.Runtime.Out.WriteLine("!!! Free space corruption at:" + node._peer._key);
                    break;
                }
            }
        }
Ejemplo n.º 10
0
 public virtual Msg ReplyFromServer()
 {
     Unmarshall();
     try
     {
         lock (ContainerLock())
         {
             ClassInfo       classInfo       = (ClassInfo)ReadObjectFromPayLoad();
             ClassInfoHelper classInfoHelper = ServerMessageDispatcher().ClassInfoHelper();
             GenericClass    genericClass    = classInfoHelper.ClassMetaToGenericClass(Container().Reflector
                                                                                           (), classInfo);
             if (genericClass != null)
             {
                 Transaction   trans         = Container().SystemTransaction();
                 ClassMetadata classMetadata = Container().ProduceClassMetadata(genericClass);
                 if (classMetadata != null)
                 {
                     Container().CheckStillToSet();
                     classMetadata.SetStateDirty();
                     classMetadata.Write(trans);
                     trans.Commit();
                     StatefulBuffer returnBytes = Container().ReadStatefulBufferById(trans, classMetadata
                                                                                     .GetID());
                     return(Msg.ObjectToClient.GetWriter(returnBytes));
                 }
             }
         }
     }
     catch (Exception e)
     {
     }
     return(Msg.Failed);
 }
Ejemplo n.º 11
0
 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);
 }
Ejemplo n.º 12
0
        /// <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
                                                            ()));
        }
Ejemplo n.º 13
0
 public virtual Db4objects.Db4o.CS.Internal.Messages.MsgD GetWriter(StatefulBuffer
                                                                    bytes)
 {
     Db4objects.Db4o.CS.Internal.Messages.MsgD message = GetWriterForLength(bytes.Transaction
                                                                                (), bytes.Length());
     message._payLoad.Append(bytes._buffer);
     return(message);
 }
Ejemplo n.º 14
0
        public override MsgD GetWriter(StatefulBuffer bytes)
        {
            var message = GetWriterForLength(bytes.Transaction(), bytes.Length() + Const4.IntLength
                                             );

            message._payLoad.WriteInt(bytes.GetAddress());
            message._payLoad.Append(bytes._buffer);
            return(message);
        }
Ejemplo n.º 15
0
        public virtual MsgD GetWriter(StatefulBuffer
                                      bytes)
        {
            var message = GetWriterForLength(bytes.Transaction
                                                 (), bytes.Length());

            message._payLoad.Append(bytes._buffer);
            return(message);
        }
Ejemplo n.º 16
0
        /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
        public static Db4objects.Db4o.CS.Internal.Messages.Msg ReadMessage(IMessageDispatcher
                                                                           messageDispatcher, Db4objects.Db4o.Internal.Transaction trans, Socket4Adapter socket
                                                                           )
        {
            StatefulBuffer reader = ReadMessageBuffer(trans, socket);

            Db4objects.Db4o.CS.Internal.Messages.Msg message = _messages[reader.ReadInt()].ReadPayLoad
                                                                   (messageDispatcher, trans, socket, reader);
            return(message);
        }
Ejemplo n.º 17
0
        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());
        }
Ejemplo n.º 18
0
        /// <exception cref="Db4objects.Db4o.Internal.FieldIndexException"></exception>
        protected virtual void RebuildIndexForObject(LocalObjectContainer container, int
                                                     objectId)
        {
            StatefulBuffer writer = container.ReadStatefulBufferById(container.SystemTransaction
                                                                         (), objectId);

            if (writer != null)
            {
                RebuildIndexForWriter(container, writer, objectId);
            }
        }
Ejemplo n.º 19
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();
        }
Ejemplo n.º 20
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);
 }
Ejemplo n.º 21
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)
        {
            int payLoadOffSet = buffer.ReadInt();
            int length        = buffer.ReadInt();

            if (payLoadOffSet == 0)
            {
                return(null);
            }
            return(buffer.ReadPayloadWriter(payLoadOffSet, length));
        }
Ejemplo n.º 22
0
        private MsgD BuildQueryResultMessage(int queryResultId, IIntIterator4 ids, int maxCount
                                             , ObjectExchangeConfiguration config)
        {
            ByteArrayBuffer payload = ObjectExchangeStrategyFactory.ForConfig(config).Marshall
                                          ((LocalTransaction)Transaction(), ids, maxCount);
            MsgD message = QueryResult.GetWriterForLength(Transaction(), Const4.IntLength + payload
                                                          .Length());
            StatefulBuffer writer = message.PayLoad();

            writer.WriteInt(queryResultId);
            writer.WriteBytes(payload._buffer);
            return(message);
        }
Ejemplo n.º 23
0
        protected virtual void WriteTransactionPointer(Transaction systemTransaction, int
                                                       transactionPointer, int address, int offset)
        {
            StatefulBuffer 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();
        }
Ejemplo n.º 24
0
                public void Visit(object treeInt)
                {
                    int            id     = ((TreeInt)treeInt)._key;
                    StatefulBuffer reader = stream.ReadStatefulBufferById(this._enclosing._enclosing.
                                                                          _trans, id);

                    if (reader != null)
                    {
                        ObjectHeader     oh      = new ObjectHeader(stream, reader);
                        CollectIdContext context = new CollectIdContext(this._enclosing._enclosing._trans
                                                                        , oh, reader);
                        oh.ClassMetadata().CollectIDs(context, fieldName);
                        Tree.Traverse(context.Ids(), new _IVisitor4_394(idsNew));
                    }
                }
Ejemplo n.º 25
0
        public static Db4objects.Db4o.Internal.Marshall.CollectIdContext ForID(Transaction
                                                                               transaction, IdObjectCollector collector, int id)
        {
            StatefulBuffer reader = transaction.Container().ReadStatefulBufferById(transaction
                                                                                   , id);

            if (reader == null)
            {
                return(null);
            }
            ObjectHeader oh = new ObjectHeader(transaction.Container(), reader);

            return(new Db4objects.Db4o.Internal.Marshall.CollectIdContext(transaction, collector
                                                                          , oh, reader));
        }
Ejemplo n.º 26
0
        public sealed override StatefulBuffer ReadStatefulBufferById(Transaction a_ta, int
                                                                     a_id, bool lastCommitted)
        {
            MsgD msg = Msg.ReadObject.GetWriterForInts(a_ta, new int[] { a_id, lastCommitted ?
                                                                         1 : 0 });

            Write(msg);
            StatefulBuffer bytes = ((MsgObject)ExpectedResponse(Msg.ObjectToClient)).Unmarshall
                                       ();

            if (bytes != null)
            {
                bytes.SetTransaction(a_ta);
            }
            return(bytes);
        }
Ejemplo n.º 27
0
        public override bool CreateClassMetadata(ClassMetadata clazz, IReflectClass claxx
                                                 , ClassMetadata superClazz)
        {
            Write(Msg.CreateClass.GetWriterForString(SystemTransaction(), Config().ResolveAliasRuntimeName
                                                         (claxx.GetName())));
            Msg resp = GetResponse();

            if (resp == null)
            {
                return(false);
            }
            if (resp.Equals(Msg.Failed))
            {
                // if the class can not be created on the server, send class meta to the server.
                SendClassMeta(claxx);
                resp = GetResponse();
            }
            if (resp.Equals(Msg.Failed))
            {
                if (ConfigImpl.ExceptionsOnNotStorable())
                {
                    throw new ObjectNotStorableException(claxx);
                }
                return(false);
            }
            if (!resp.Equals(Msg.ObjectToClient))
            {
                return(false);
            }
            MsgObject      message = (MsgObject)resp;
            StatefulBuffer bytes   = message.Unmarshall();

            if (bytes == null)
            {
                return(false);
            }
            bytes.SetTransaction(SystemTransaction());
            if (!base.CreateClassMetadata(clazz, claxx, superClazz))
            {
                return(false);
            }
            clazz.SetID(message.GetId());
            clazz.ReadName1(SystemTransaction(), bytes);
            ClassCollection().AddClassMetadata(clazz);
            ClassCollection().ReadClassMetadata(clazz, claxx);
            return(true);
        }
Ejemplo n.º 28
0
        /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
        protected static StatefulBuffer ReadMessageBuffer(Db4objects.Db4o.Internal.Transaction
                                                          trans, Socket4Adapter socket, int length)
        {
            StatefulBuffer buffer = new StatefulBuffer(trans, length);
            int            offset = 0;

            while (length > 0)
            {
                int read = socket.Read(buffer._buffer, offset, length);
                if (read < 0)
                {
                    throw new Db4oIOException();
                }
                offset += read;
                length -= read;
            }
            return(buffer);
        }
Ejemplo n.º 29
0
        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));
        }
Ejemplo n.º 30
0
        public Msg ReplyFromServer()
        {
            var address = ReadInt();
            var length  = ReadInt();

            lock (ContainerLock())
            {
                var bytes = new StatefulBuffer(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(Null);
                }
            }
        }
Ejemplo n.º 31
0
 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);
         }
     }
 }
Ejemplo n.º 33
0
        public override ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
        {
            int id     = 0;
            int offset = context.Offset();

            try
            {
                id = context.ReadInt();
            }
            catch (Exception)
            {
            }
            context.Seek(offset);
            if (id != 0)
            {
                StatefulBuffer reader = context.Container().ReadStatefulBufferById(context.Transaction
                                                                                       (), id);
                if (reader != null)
                {
                    ObjectHeader oh = new ObjectHeader(context.Container(), reader);
                    try
                    {
                        if (oh.ClassMetadata() != null)
                        {
                            context.Buffer(reader);
                            return(oh.ClassMetadata().SeekCandidateHandler(context));
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            // TODO: Check Exception Types
            // Errors typically occur, if classes don't match
            return(null);
        }
Ejemplo n.º 34
0
        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();
        }
Ejemplo n.º 35
0
        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);
                }
            }
        }
Ejemplo n.º 36
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());
 }
Ejemplo n.º 37
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();
 }
Ejemplo n.º 38
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);
 }
Ejemplo n.º 39
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 public object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer statefulBuffer
     )
 {
     return Read(mf, statefulBuffer, true);
 }
Ejemplo n.º 40
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);
Ejemplo n.º 41
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();
 }
Ejemplo n.º 42
0
 public override void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread
     , bool shuttingDown, StatefulBuffer writer, int blockSize)
 {
     throw new InvalidOperationException();
 }
Ejemplo n.º 43
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 public object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer statefulBuffer
     )
 {
     return ReadIndexEntry(statefulBuffer.Transaction().Context(), statefulBuffer);
 }
Ejemplo n.º 44
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);
 }
Ejemplo n.º 45
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();
 }
Ejemplo n.º 46
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 public override object Read(MarshallerFamily mf, StatefulBuffer buffer, bool redirect
     )
 {
     return mf._primitive.ReadShort(buffer);
 }
Ejemplo n.º 47
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 public override object Read(MarshallerFamily mf, StatefulBuffer writer, bool redirect
     )
 {
     return mf._primitive.ReadFloat(writer);
 }