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);
			}
		}
        /// <exception cref="Db4objects.Db4o.Internal.FieldIndexException"></exception>
        public override void AddFieldIndex(ObjectIdContextImpl context)
        {
            LocalTransaction     transaction    = (LocalTransaction)context.Transaction();
            LocalObjectContainer localContainer = (LocalObjectContainer)transaction.Container
                                                      ();
            Slot oldSlot                = transaction.IdSystem().CommittedSlot(context.ObjectId());
            int  savedOffset            = context.Offset();
            int  db4oDatabaseIdentityID = context.ReadInt();
            long uuid = context.ReadLong();

            context.Seek(savedOffset);
            bool isnew = (oldSlot.IsNull());

            if ((uuid == 0 || db4oDatabaseIdentityID == 0) && context.ObjectId() > 0 && !isnew)
            {
                UUIDFieldMetadata.DatabaseIdentityIDAndUUID identityAndUUID = ReadDatabaseIdentityIDAndUUID
                                                                                  (localContainer, context.ClassMetadata(), oldSlot, false);
                db4oDatabaseIdentityID = identityAndUUID.databaseIdentityID;
                uuid = identityAndUUID.uuid;
            }
            if (db4oDatabaseIdentityID == 0)
            {
                db4oDatabaseIdentityID = localContainer.Identity().GetID(transaction);
            }
            if (uuid == 0)
            {
                uuid = localContainer.GenerateTimeStampId();
            }
            StatefulBuffer writer = (StatefulBuffer)context.Buffer();

            writer.WriteInt(db4oDatabaseIdentityID);
            writer.WriteLong(uuid);
            if (isnew)
            {
                AddIndexEntry(writer, uuid);
            }
        }
示例#3
0
        /// <exception cref="Db4objects.Db4o.Internal.FieldIndexException"></exception>
        public override void AddFieldIndex(ObjectIdContextImpl context)
        {
            StatefulBuffer buffer = (StatefulBuffer)context.Buffer();

            buffer.WriteLong(context.Transaction().Container().GenerateTimeStampId());
        }