コード例 #1
0
 @Override
 boolean evolve(Format newFormatParam, Evolver evolver) {
   if (!(newFormatParam instanceof ProxiedFormat)) {
     evolver.addEvolveError(
         this, newFormatParam, null, "A proxied class may not be changed to a different type");
     return false;
   }
   ProxiedFormat newFormat = (ProxiedFormat) newFormatParam;
   if (!evolver.evolveFormat(proxyFormat)) {
     return false;
   }
   Format newProxyFormat = proxyFormat.getLatestVersion();
   if (!newProxyFormat.getClassName().equals(newFormat.getProxyClassName())) {
     evolver.addEvolveError(
         this,
         newFormat,
         null,
         "The proxy class for this type has been changed from: "
             + newProxyFormat.getClassName()
             + " to: "
             + newFormat.getProxyClassName());
     return false;
   }
   if (newProxyFormat != proxyFormat) {
     evolver.useEvolvedFormat(this, this, newFormat);
   } else {
     evolver.useOldFormat(this, newFormat);
   }
   return true;
 }
コード例 #2
0
 @Override
 void initialize(Catalog catalog, EntityModel model, int initVersion) {
   /* Set the component format for a new (never initialized) format. */
   if (componentFormat == null) {
     Class cls = getType().getComponentType();
     componentFormat = catalog.getFormat(cls.getName());
   }
   useComponentFormat = componentFormat.getLatestVersion();
 }
コード例 #3
0
  @Override
  boolean evolve(Format newFormat, Evolver evolver) {

    /*
     * When the class name of the component changes, we need a new format
     * that references it.  Otherwise, don't propogate changes from
     * components upward to their arrays.
     */
    Format latest = componentFormat.getLatestVersion();
    if (latest != componentFormat
        && !latest.getClassName().equals(componentFormat.getClassName())) {
      evolver.useEvolvedFormat(this, newFormat, newFormat);
    } else {
      evolver.useOldFormat(this, newFormat);
    }
    return true;
  }
  /**
   * Creates the instance, reads the entity key first to track visited entities correctly, then
   * reads the data and returns the entity.
   *
   * <p>This is a special case of EntityInput.readObject for a top level entity. Special treatments
   * are: - The formatId must be >= 0; since this is the top level instance, it cannot refer to a
   * visited object nor be a null reference. - The entity is not checked for existence in the
   * visited object set; entities cannot be referenced by another entity. - Reader.readPriKey must
   * be called prior to calling Reader.readObject.
   */
  static Object readEntity(
      Catalog useCatalog, DatabaseEntry key, Object priKey, DatabaseEntry data, boolean rawAccess)
      throws RefreshException {

    RecordInput dataInput =
        new RecordInput(
            useCatalog, rawAccess, null, 0, data.getData(), data.getOffset(), data.getSize());
    int initialOffset = dataInput.getBufferOffset();
    int formatId = dataInput.readPackedInt();
    Format format = useCatalog.getFormat(formatId, true /*expectStored*/);
    dataInput.registerEntityFormat(format);
    Reader reader = format.getReader();
    Object entity = reader.newInstance(dataInput, rawAccess);
    if (priKey == null) {
      /* If priKey is null, need to deserialize the primary key. */
      RecordInput keyInput =
          new RecordInput(
              useCatalog, rawAccess, null, 0, key.getData(), key.getOffset(), key.getSize());
      reader.readPriKey(entity, keyInput, rawAccess);
    } else {

      /*
       * If priKey is not null, directly assign it to the primary key
       * field. [#19248]
       */
      Accessor accessor = reader.getAccessor(entity instanceof RawObject ? true : rawAccess);
      if (accessor == null) {
        accessor =
            format
                .getLatestVersion()
                .getReader()
                .getAccessor(entity instanceof RawObject ? true : rawAccess);
      }
      accessor.setPriField(entity, priKey);
    }
    dataInput.registerEntity(entity, initialOffset);
    entity = reader.readObject(entity, dataInput, rawAccess);
    return entity;
  }