Example #1
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);
     }
 }
Example #2
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);
     }
 }