コード例 #1
0
  public void processClassCollection(final DefragmentServicesImpl services)
      throws CorruptionException, IOException {
    DefragmentContextImpl.processCopy(
        services,
        services.sourceClassCollectionID(),
        new SlotCopyHandler() {
          public void processCopy(DefragmentContextImpl context) {
            if (Deploy.debug) {
              context.readBegin(Const4.YAPCLASSCOLLECTION);
            }

            int acceptedClasses = 0;
            int numClassesOffset = context.targetBuffer().offset();
            acceptedClasses = copyAcceptedClasses(context, acceptedClasses);
            writeIntAt(context.targetBuffer(), numClassesOffset, acceptedClasses);

            if (Deploy.debug) {
              context.readEnd();
            }
          }

          private int copyAcceptedClasses(DefragmentContextImpl context, int acceptedClasses) {
            int numClasses = context.readInt();
            for (int classIdx = 0; classIdx < numClasses; classIdx++) {
              int classId = context.sourceBuffer().readInt();
              if (!accept(classId)) {
                continue;
              }
              ++acceptedClasses;
              context.writeMappedID(classId);
            }
            return acceptedClasses;
          }

          private void writeIntAt(ByteArrayBuffer target, int offset, int value) {
            int currentOffset = target.offset();
            target.seek(offset);
            target.writeInt(value);
            target.seek(currentOffset);
          }

          private boolean accept(int classId) {
            return services.accept(services.classMetadataForId(classId));
          }
        });
  }
コード例 #2
0
 public void processClass(
     final DefragmentServicesImpl services,
     final ClassMetadata classMetadata,
     int id,
     final int classIndexID)
     throws CorruptionException, IOException {
   if (services.mappedID(id, -1) == -1) {
     System.err.println("MAPPING NOT FOUND: " + id);
   }
   DefragmentContextImpl.processCopy(
       services,
       id,
       new SlotCopyHandler() {
         public void processCopy(DefragmentContextImpl context) {
           classMetadata.defragClass(context, classIndexID);
         }
       });
 }
コード例 #3
0
 public void processObjectSlot(
     final DefragmentServicesImpl services, final ClassMetadata classMetadata, int id)
     throws CorruptionException, IOException {
   ByteArrayBuffer sourceBuffer = services.sourceBufferByID(id);
   DefragmentContextImpl.processCopy(
       services,
       id,
       new SlotCopyHandler() {
         public void processCopy(DefragmentContextImpl context) {
           ClassMetadata.defragObject(context);
           if (_objectCommitFrequency > 0) {
             _objectCount++;
             if (_objectCount == _objectCommitFrequency) {
               services.targetCommit();
               services.mapping().commit();
               _objectCount = 0;
             }
           }
         }
       },
       sourceBuffer);
 }
コード例 #4
0
  public void defrag(
      final ClassMetadata classMetadata,
      final LatinStringIO sio,
      final DefragmentContextImpl context,
      int classIndexID) {
    readName(sio, context.sourceBuffer());
    readName(sio, context.targetBuffer());

    int metaClassID = 0;
    context.writeInt(metaClassID);

    // ancestor ID
    context.copyID();

    context.writeInt(indexIDForWriting(classIndexID));

    final int aspectCount = context.readInt();

    if (aspectCount > classMetadata.declaredAspectCount()) {
      throw new IllegalStateException();
    }

    final IntByRef processedAspectCount = new IntByRef(0);

    classMetadata.forEachDeclaredAspect(
        new Procedure4() {
          public void apply(Object arg) {
            if (processedAspectCount.value >= aspectCount) {
              return;
            }
            ClassAspect aspect = (ClassAspect) arg;
            _family._field.defrag(classMetadata, aspect, sio, context);
            processedAspectCount.value++;
          }
        });
  }