示例#1
0
        public override void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO
                                    sio, DefragmentContextImpl context)
        {
            base.Defrag(classMetadata, aspect, sio, context);
            if (!(aspect is FieldMetadata))
            {
                return;
            }
            var field = (FieldMetadata)aspect;

            if (field.IsVirtual())
            {
                return;
            }
            if (field.HasIndex())
            {
                var index         = field.GetIndex(context.SystemTrans());
                var targetIndexID = context.CopyID();
                if (targetIndexID != 0)
                {
                    index.DefragBTree(context.Services());
                }
            }
            else
            {
                context.WriteInt(0);
            }
        }
示例#2
0
 public virtual void DefragBTree(IDefragmentServices services)
 {
     DefragmentContextImpl.ProcessCopy(services, GetID(), new _ISlotCopyHandler_481(this
                                                                                    ));
     services.TraverseAllIndexSlots(this, new _IVisitor4_486(this, services));
     ConvertCacheEvictedNodesToReadMode();
 }
        public override void DefragReference(ClassMetadata classMetadata, DefragmentContextImpl
                                             context, int classIndexID)
        {
            int newID = -classIndexID;

            context.WriteInt(newID);
        }
示例#4
0
        public static void Defragment(IDefragmentContext context, ArrayHandler handler)
        {
            int sourceAddress = context.SourceBuffer().ReadInt();
            int length        = context.SourceBuffer().ReadInt();

            if (sourceAddress == 0 && length == 0)
            {
                context.TargetBuffer().WriteInt(0);
                context.TargetBuffer().WriteInt(0);
                return;
            }
            Slot            slot         = context.AllocateMappedTargetSlot(sourceAddress, length);
            ByteArrayBuffer sourceBuffer = null;

            try
            {
                sourceBuffer = context.SourceBufferByAddress(sourceAddress, length);
            }
            catch (IOException exc)
            {
                throw new Db4oIOException(exc);
            }
            DefragmentContextImpl payloadContext = new DefragmentContextImpl(sourceBuffer, (DefragmentContextImpl
                                                                                            )context);

            handler.DefragmentSlot(payloadContext);
            payloadContext.WriteToTarget(slot.Address());
            context.TargetBuffer().WriteInt(slot.Address());
            context.TargetBuffer().WriteInt(length);
        }
示例#5
0
        /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        public void ProcessObjectSlot(DefragmentServicesImpl services, ClassMetadata classMetadata
                                      , int id)
        {
            ByteArrayBuffer sourceBuffer = services.SourceBufferByID(id);

            DefragmentContextImpl.ProcessCopy(services, id, new _ISlotCopyHandler_43(this, services
                                                                                     ), sourceBuffer);
        }
示例#6
0
            public void ProcessCopy(DefragmentContextImpl context)
            {
                int acceptedClasses  = 0;
                int numClassesOffset = context.TargetBuffer().Offset();

                acceptedClasses = this.CopyAcceptedClasses(context, acceptedClasses);
                this.WriteIntAt(context.TargetBuffer(), numClassesOffset, acceptedClasses);
            }
示例#7
0
            public void ProcessCopy(DefragmentContextImpl context)
            {
                var acceptedClasses  = 0;
                var numClassesOffset = context.TargetBuffer().Offset();

                acceptedClasses = CopyAcceptedClasses(context, acceptedClasses);
                WriteIntAt(context.TargetBuffer(), numClassesOffset, acceptedClasses);
            }
示例#8
0
        private static void DefragUnindexed(DefragmentServicesImpl services)
        {
            IdSource unindexedIDs = services.UnindexedIDs();

            while (unindexedIDs.HasMoreIds())
            {
                int origID = unindexedIDs.NextId();
                DefragmentContextImpl.ProcessCopy(services, origID, new _ISlotCopyHandler_208());
            }
        }
示例#9
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public void ProcessClass(DefragmentServicesImpl services, ClassMetadata classMetadata
                          , int id, int classIndexID)
 {
     if (services.MappedID(id, -1) == -1)
     {
         Sharpen.Runtime.Err.WriteLine("MAPPING NOT FOUND: " + id);
     }
     DefragmentContextImpl.ProcessCopy(services, id, new _ISlotCopyHandler_34(classMetadata
                                                                              , classIndexID));
 }
示例#10
0
 public _IProcedure4_136(ClassMarshaller _enclosing, IntByRef processedAspectCount
                         , int aspectCount, ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl
                         context)
 {
     this._enclosing           = _enclosing;
     this.processedAspectCount = processedAspectCount;
     this.aspectCount          = aspectCount;
     this.classMetadata        = classMetadata;
     this.sio     = sio;
     this.context = context;
 }
 public virtual void DefragIndexEntry(DefragmentContextImpl context)
 {
     try
     {
         Read1(context.SourceBuffer());
         Read1(context.TargetBuffer());
     }
     catch (CorruptionException)
     {
         Exceptions4.VirtualException();
     }
 }
示例#12
0
 public void ProcessCopy(DefragmentContextImpl context)
 {
     ClassMetadata.DefragObject(context);
     if (this._enclosing._objectCommitFrequency > 0)
     {
         this._enclosing._objectCount++;
         if (this._enclosing._objectCount == this._enclosing._objectCommitFrequency)
         {
             services.TargetCommit();
             services.Mapping().Commit();
             this._enclosing._objectCount = 0;
         }
     }
 }
示例#13
0
 public static ObjectHeader Defrag(DefragmentContextImpl
     context)
 {
     var source = context.SourceBuffer();
     var target = context.TargetBuffer();
     var header = new ObjectHeader
         (context.Services().SystemTrans().Container(), null, source);
     var newID = context.Mapping().StrictMappedID(header.ClassMetadata().GetID());
     var slotFormat = header.SlotFormat();
     slotFormat.WriteObjectClassID(target, newID);
     slotFormat.SkipMarshallerInfo(target);
     slotFormat.ReadHeaderAttributes(target);
     return header;
 }
示例#14
0
        public static ObjectHeader Defrag(DefragmentContextImpl
                                          context)
        {
            var source = context.SourceBuffer();
            var target = context.TargetBuffer();
            var header = new ObjectHeader
                             (context.Services().SystemTrans().Container(), null, source);
            var newID      = context.Mapping().StrictMappedID(header.ClassMetadata().GetID());
            var slotFormat = header.SlotFormat();

            slotFormat.WriteObjectClassID(target, newID);
            slotFormat.SkipMarshallerInfo(target);
            slotFormat.ReadHeaderAttributes(target);
            return(header);
        }
示例#15
0
 public override void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO
                             sio, DefragmentContextImpl context)
 {
     context.IncrementStringOffset(sio);
     if (!(aspect is FieldMetadata))
     {
         return;
     }
     if (((FieldMetadata)aspect).IsVirtual())
     {
         return;
     }
     // handler ID
     context.CopyID();
     // skip primitive/array/narray attributes
     context.IncrementOffset(1);
 }
示例#16
0
            private int CopyAcceptedClasses(DefragmentContextImpl context, int acceptedClasses
                                            )
            {
                int numClasses = context.ReadInt();

                for (int classIdx = 0; classIdx < numClasses; classIdx++)
                {
                    int classId = context.SourceBuffer().ReadInt();
                    if (!this.Accept(classId))
                    {
                        continue;
                    }
                    ++acceptedClasses;
                    context.WriteMappedID(classId);
                }
                return(acceptedClasses);
            }
示例#17
0
        public virtual void Defrag(ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl
                                   context, int classIndexID)
        {
            ReadName(sio, context.SourceBuffer());
            ReadName(sio, context.TargetBuffer());
            int metaClassID = 0;

            context.WriteInt(metaClassID);
            // ancestor ID
            context.CopyID();
            context.WriteInt((classMetadata.HasClassIndex() ? IndexIDForWriting(classIndexID)
                                 : 0));
            int aspectCount = context.ReadInt();

            if (aspectCount > classMetadata.DeclaredAspectCount())
            {
                throw new InvalidOperationException();
            }
            IntByRef processedAspectCount = new IntByRef(0);

            classMetadata.TraverseDeclaredAspects(new _IProcedure4_136(this, processedAspectCount
                                                                       , aspectCount, classMetadata, sio, context));
        }
示例#18
0
 private int CopyDependentSlot(IDefragmentContext context, int sourceId)
 {
     try
     {
         ByteArrayBuffer sourceBuffer      = context.SourceBufferById(sourceId);
         Slot            targetPayloadSlot = context.AllocateTargetSlot(sourceBuffer.Length());
         int             targetId          = context.Services().TargetNewId();
         context.Services().MapIDs(sourceId, targetId, false);
         context.Services().Mapping().MapId(targetId, targetPayloadSlot);
         DefragmentContextImpl payloadContext = new DefragmentContextImpl(sourceBuffer, (DefragmentContextImpl
                                                                                         )context);
         int           clazzId                 = payloadContext.CopyIDReturnOriginalID();
         ITypeHandler4 payloadHandler          = payloadContext.TypeHandlerForId(clazzId);
         ITypeHandler4 versionedPayloadHandler = HandlerRegistry.CorrectHandlerVersion(payloadContext
                                                                                       , payloadHandler);
         versionedPayloadHandler.Defragment(payloadContext);
         payloadContext.WriteToTarget(targetPayloadSlot.Address());
         return(targetId);
     }
     catch (IOException ioexc)
     {
         throw new Db4oIOException(ioexc);
     }
 }
示例#19
0
        public static void DefragIndex(DefragmentContextImpl context, IIndexable4 keyHandler
                                       )
        {
            // count
            int count = context.ReadInt();
            // leafByte
            byte leafByte = context.ReadByte();
            bool isLeaf   = (leafByte == 1);

            context.CopyID();
            // parent ID
            context.CopyID();
            // previous ID
            context.CopyID();
            // next ID
            for (int i = 0; i < count; i++)
            {
                keyHandler.DefragIndexEntry(context);
                if (!isLeaf)
                {
                    context.CopyID();
                }
            }
        }
示例#20
0
文件: BTree.cs 项目: masroore/db4o
 public void ProcessCopy(DefragmentContextImpl context)
 {
     _enclosing._enclosing.DefragIndexNode(context);
 }
示例#21
0
 public override void DefragIndexEntry(DefragmentContextImpl context)
 {
     context.IncrementIntSize();
 }
示例#22
0
 /// <exception cref="Db4objects.Db4o.CorruptionException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public void ProcessClassCollection(DefragmentServicesImpl services)
 {
     DefragmentContextImpl.ProcessCopy(services, services.SourceClassCollectionID(), new
                                       _ISlotCopyHandler_59(services));
 }
示例#23
0
 public virtual void DefragIndexEntry(DefragmentContextImpl context)
 {
     throw new NotImplementedException();
 }
示例#24
0
 public virtual void DefragIndexEntry(DefragmentContextImpl context)
 {
     context.CopyAddress();
     // length
     context.IncrementIntSize();
 }
 public override void DefragIndex(DefragmentContextImpl context)
 {
     _btreeIndex.DefragIndex(context);
 }
示例#26
0
 public static void Defragment(IDefragmentContext context, ArrayHandler handler)
 {
     var sourceAddress = context.SourceBuffer().ReadInt();
     var length = context.SourceBuffer().ReadInt();
     if (sourceAddress == 0 && length == 0)
     {
         context.TargetBuffer().WriteInt(0);
         context.TargetBuffer().WriteInt(0);
         return;
     }
     var slot = context.AllocateMappedTargetSlot(sourceAddress, length);
     ByteArrayBuffer sourceBuffer = null;
     try
     {
         sourceBuffer = context.SourceBufferByAddress(sourceAddress, length);
     }
     catch (IOException exc)
     {
         throw new Db4oIOException(exc);
     }
     var payloadContext = new DefragmentContextImpl(sourceBuffer, (DefragmentContextImpl
         ) context);
     handler.DefragmentSlot(payloadContext);
     payloadContext.WriteToTarget(slot.Address());
     context.TargetBuffer().WriteInt(slot.Address());
     context.TargetBuffer().WriteInt(length);
 }
示例#27
0
 public override void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO
     sio, DefragmentContextImpl context)
 {
     context.ReadByte();
     base.Defrag(classMetadata, aspect, sio, context);
 }
示例#28
0
 public void ProcessCopy(DefragmentContextImpl context)
 {
     ClassMetadata.DefragObject(context);
 }
示例#29
0
文件: BTree.cs 项目: masroore/db4o
 public virtual void DefragIndex(DefragmentContextImpl context)
 {
     context.IncrementOffset(DefragmentIncrementOffset);
     context.CopyID();
 }
示例#30
0
 public void DefragIndexEntry(DefragmentContextImpl context)
 {
     context.IncrementOffset(Const4.LongLength);
 }
示例#31
0
 public override void DefragIndex(DefragmentContextImpl context)
 {
     _btreeIndex.DefragIndex(context);
 }
示例#32
0
 public virtual void DefragIndexEntry(DefragmentContextImpl context)
 {
     throw new NotImplementedException();
 }
示例#33
0
 public virtual void DefragIndexEntry(DefragmentContextImpl context)
 {
     _parentIdHandler.DefragIndexEntry(context);
     _valueHandler.DefragIndexEntry(context);
 }
示例#34
0
 private int CopyDependentSlot(IDefragmentContext context, int sourceId)
 {
     try
     {
         var sourceBuffer = context.SourceBufferById(sourceId);
         var targetPayloadSlot = context.AllocateTargetSlot(sourceBuffer.Length());
         var targetId = context.Services().TargetNewId();
         context.Services().MapIDs(sourceId, targetId, false);
         context.Services().Mapping().MapId(targetId, targetPayloadSlot);
         var payloadContext = new DefragmentContextImpl(sourceBuffer, (DefragmentContextImpl
             ) context);
         var clazzId = payloadContext.CopyIDReturnOriginalID();
         var payloadHandler = payloadContext.TypeHandlerForId(clazzId);
         var versionedPayloadHandler = HandlerRegistry.CorrectHandlerVersion(payloadContext
             , payloadHandler);
         versionedPayloadHandler.Defragment(payloadContext);
         payloadContext.WriteToTarget(targetPayloadSlot.Address());
         return targetId;
     }
     catch (IOException ioexc)
     {
         throw new Db4oIOException(ioexc);
     }
 }
示例#35
0
 public void ProcessCopy(DefragmentContextImpl context)
 {
     classMetadata.DefragClass(context, classIndexID);
 }
示例#36
0
 public override void DefragReference(ClassMetadata classMetadata, DefragmentContextImpl
     context, int classIndexID)
 {
     var newID = -classIndexID;
     context.WriteInt(newID);
 }
示例#37
0
 public virtual void DefragIndexEntry(DefragmentContextImpl context)
 {
     _parentIdHandler.DefragIndexEntry(context);
     _valueHandler.DefragIndexEntry(context);
 }
示例#38
0
 public override void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO
     sio, DefragmentContextImpl context)
 {
     base.Defrag(classMetadata, aspect, sio, context);
     if (!(aspect is FieldMetadata))
     {
         return;
     }
     var field = (FieldMetadata) aspect;
     if (field.IsVirtual())
     {
         return;
     }
     if (field.HasIndex())
     {
         var index = field.GetIndex(context.SystemTrans());
         var targetIndexID = context.CopyID();
         if (targetIndexID != 0)
         {
             index.DefragBTree(context.Services());
         }
     }
     else
     {
         context.WriteInt(0);
     }
 }
示例#39
0
 void IIndexable4.DefragIndexEntry(DefragmentContextImpl context)
 {
     IncrementOffset(context);
 }
示例#40
0
 public override void DefragIndexEntry(DefragmentContextImpl context)
 {
     context.IncrementIntSize();
 }
示例#41
0
 public virtual void DefragIndexEntry(DefragmentContextImpl context)
 {
     context.CopyAddress();
     // length
     context.IncrementIntSize();
 }
示例#42
0
 public static void DefragIndex(DefragmentContextImpl context, IIndexable4 keyHandler
     )
 {
     // count
     var count = context.ReadInt();
     // leafByte
     var leafByte = context.ReadByte();
     var isLeaf = (leafByte == 1);
     context.CopyID();
     // parent ID
     context.CopyID();
     // previous ID
     context.CopyID();
     // next ID
     for (var i = 0; i < count; i++)
     {
         keyHandler.DefragIndexEntry(context);
         if (!isLeaf)
         {
             context.CopyID();
         }
     }
 }
 public void DefragIndexEntry(DefragmentContextImpl context)
 {
     context.CopyID();
 }
示例#44
0
 public override void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO
     sio, DefragmentContextImpl context)
 {
     context.IncrementStringOffset(sio);
     if (!(aspect is FieldMetadata))
     {
         return;
     }
     if (((FieldMetadata) aspect).IsVirtual())
     {
         return;
     }
     // handler ID
     context.CopyID();
     // skip primitive/array/narray attributes
     context.IncrementOffset(1);
 }
示例#45
0
 public abstract void Defrag(ClassMetadata arg1, ClassAspect arg2, LatinStringIO arg3
     , DefragmentContextImpl arg4);
示例#46
0
 public _IProcedure4_136(ClassMarshaller _enclosing, IntByRef processedAspectCount
     , int aspectCount, ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl
         context)
 {
     this._enclosing = _enclosing;
     this.processedAspectCount = processedAspectCount;
     this.aspectCount = aspectCount;
     this.classMetadata = classMetadata;
     this.sio = sio;
     this.context = context;
 }
示例#47
0
文件: BTree.cs 项目: masroore/db4o
 public virtual void DefragIndexNode(DefragmentContextImpl context)
 {
     BTreeNode.DefragIndex(context, _keyHandler);
 }
示例#48
0
 public abstract void DefragIndex(DefragmentContextImpl arg1);
示例#49
0
 public virtual void DefragIndexEntry(DefragmentContextImpl context)
 {
     try
     {
         Read1(context.SourceBuffer());
         Read1(context.TargetBuffer());
     }
     catch (CorruptionException)
     {
         Exceptions4.VirtualException();
     }
 }
示例#50
0
 public override void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO
                             sio, DefragmentContextImpl context)
 {
     context.ReadByte();
     base.Defrag(classMetadata, aspect, sio, context);
 }
示例#51
0
 public abstract void DefragReference(ClassMetadata arg1, DefragmentContextImpl arg2
     , int arg3);
 public void DefragIndexEntry(DefragmentContextImpl context)
 {
     context.CopyID();
 }
示例#53
0
 public virtual void Defrag(ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl
     context, int classIndexID)
 {
     ReadName(sio, context.SourceBuffer());
     ReadName(sio, context.TargetBuffer());
     var metaClassID = 0;
     context.WriteInt(metaClassID);
     // ancestor ID
     context.CopyID();
     context.WriteInt((classMetadata.HasClassIndex()
         ? IndexIDForWriting(classIndexID)
         : 0));
     var aspectCount = context.ReadInt();
     if (aspectCount > classMetadata.DeclaredAspectCount())
     {
         throw new InvalidOperationException();
     }
     var processedAspectCount = new IntByRef(0);
     classMetadata.TraverseDeclaredAspects(new _IProcedure4_136(this, processedAspectCount
         , aspectCount, classMetadata, sio, context));
 }