You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "David Bowen (JIRA)" <ji...@apache.org> on 2007/04/04 18:32:32 UTC

[jira] Commented: (HADOOP-558) Adding versioning to Writable classes

    [ https://issues.apache.org/jira/browse/HADOOP-558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486690 ] 

David Bowen commented on HADOOP-558:
------------------------------------

The suggested API is putting static methods on an interface, which isn't possible.  We need a class to put them in, so how about:

class VersionMap extends HashMap<Class<VersionMapWritable>,Integer> {
  ...
}

In addDependence, are the terms "parent" and "child" are referring to the inheritance relationship or the "contains" relationship - between a class and the classes of its fields? 

I don't understand addMethodTypes and addFieldTypes.  Please can you explain them more fully?





> Adding versioning to Writable classes
> -------------------------------------
>
>                 Key: HADOOP-558
>                 URL: https://issues.apache.org/jira/browse/HADOOP-558
>             Project: Hadoop
>          Issue Type: Improvement
>          Components: io
>    Affects Versions: 0.6.2
>            Reporter: Owen O'Malley
>         Assigned To: David Bowen
>
> We currently don't have a way to support versioned Writables, which among other problems means that it is very difficult to change the serialization of any types. (A recent example is that we can't change any of the Writables that currently use UTF8.writeString to use Text.writeString with out breaking everything.) Just changing the file version doesn't work because you can't read the old versions.
> Therefore, I propose adding a new interface:
> public interface VersionMapWritable extends Writable {
>   /**
>    * Destructively read into this object from in based on the version map.
>    * @param versionMap a map from each class to its version in the DataInput (version 0 classes are omitted)
>    */
>   public void readFields(DataInput in, Map<Class<VersionMapWritable>, int> versionMap) throws IOException;
>   /**
>    * Classes with non-zero versions should register themselves in static blocks.
>    */
>   public static void registerCurrentVersion(Class<VersionMapWritable> class, int version) {...}
>   /**
>    * If a version map includes the parent type, always include the child type as well.
>    */
>   public static void addDependence(Class<VersionMapWritable> parent, Class<VersionMapWritable> child) { ... }
>   /**
>    * Build a version map for a given list of classes, including any dependent types.
>    */
>   public static Map<Class<VersionMapWritable>, int> 
>               buildVersionMap(Set<Class<VersionMapWritable>> classes) {...}
>   /**
>    * Add the types in the parameter/result types to the list of classes.
>    * Recursively adds the field types for any new types that are added to the set.
>    */
>   public static void addMethodTypes(Set<Class<VersionMapWritable>> result, 
>                      Class<VersionedProtocol> protocol) {...}
>   /**
>    * Add the non-transient fields to the list of classes.
>    */
>   public static void addFieldTypes(Set<Class<VersionMapWritable>> result, Class<Writable> writable) {...}
>   public static Map<Class<VersionMapWritable>, int> readVersionMap(DataInput in) throws IOException { ... }
>   public static void writeVersionMap(DataOutput out, 
>                   Map<Class<VersionMapWritable> versionMap) throws IOException {...}
> }
> VersionedWritable, which stored a version byte within each object, will be depriciated.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.