hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r939412 - in /hadoop/common/trunk: ./ src/java/ src/java/org/apache/hadoop/conf/ src/java/org/apache/hadoop/io/ src/java/org/apache/hadoop/io/serializer/ src/java/org/apache/hadoop/io/serializer/avro/ src/java/org/apache/hadoop/util/ src/te...
Date Thu, 29 Apr 2010 18:09:57 GMT
Author: tomwhite
Date: Thu Apr 29 18:09:56 2010
New Revision: 939412

URL: http://svn.apache.org/viewvc?rev=939412&view=rev
Log:
HADOOP-6698. Revert the io.serialization package to 0.20.2's api. Reverted HADOOP-6165, HADOOP-6443, HADOOP-6323, and HADOOP-6420.

Removed:
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/DeserializerBase.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/LegacyDeserializer.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/LegacySerialization.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/LegacySerializer.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/SerializationBase.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/SerializerBase.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroComparator.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroGenericSerialization.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/TestRawComparators.java
Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/core-default.xml
    hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/DefaultStringifier.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Deserializer.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/DeserializerComparator.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/JavaSerialization.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Serialization.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/SerializationFactory.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/WritableSerialization.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroReflectSerialization.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSerialization.java
    hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSpecificSerialization.java
    hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/SerializationTestUtil.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/TestWritableSerialization.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/avro/TestAvroSerialization.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Thu Apr 29 18:09:56 2010
@@ -32,9 +32,6 @@ Trunk (unreleased changes)
     HADOOP-6392. Run namenode and jobtracker on separate EC2 instances.
     (tomwhite)
 
-    HADOOP-6323. Add comparators to the serialization API.
-    (Aaron Kimball via cutting)
-
     HADOOP-6433. Introduce asychronous deletion of files via a pool of
     threads. This can be used to delete files in the Distributed
     Cache. (Zheng Shao via dhruba)
@@ -129,18 +126,12 @@ Trunk (unreleased changes)
     HADOOP-6472. add tokenCache option to GenericOptionsParser for passing
      file with secret keys to a map reduce job. (boryas)
 
-    HADOOP-6443. Serialization classes accept invalid metadata.
-    (Aaron Kimball via tomwhite)
-
     HADOOP-3205. Read multiple chunks directly from FSInputChecker subclass
     into user buffers. (Todd Lipcon via tomwhite)
 
     HADOOP-6479. TestUTF8 assertions could fail with better text.
     (Steve Loughran via tomwhite)
 
-    HADOOP-6420. Add functionality permitting subsets of Configuration to be
-    interpreted as Map<String,String>. (Aaron Kimball via cdouglas)
-
     HADOOP-6155. Deprecate RecordIO anticipating Avro. (Tom White via cdouglas)
 
     HADOOP-6492. Make some Avro serialization APIs public.
@@ -564,8 +555,6 @@ Release 0.21.0 - Unreleased
     the io package and makes it available to other users (MAPREDUCE-318). 
     (Jothi Padmanabhan via ddas)
 
-    HADOOP-6165. Add metadata to Serializations. (tomwhite)
-
     HADOOP-6105. Adds support for automatically handling deprecation of
     configuration keys. (V.V.Chaitanya Krishna via yhemanth)
     

Modified: hadoop/common/trunk/src/java/core-default.xml
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/core-default.xml?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/core-default.xml (original)
+++ hadoop/common/trunk/src/java/core-default.xml Thu Apr 29 18:09:56 2010
@@ -124,7 +124,7 @@
 
 <property>
   <name>io.serializations</name>
-  <value>org.apache.hadoop.io.serializer.WritableSerialization,org.apache.hadoop.io.serializer.avro.AvroSpecificSerialization,org.apache.hadoop.io.serializer.avro.AvroReflectSerialization,org.apache.hadoop.io.serializer.avro.AvroGenericSerialization</value>
+  <value>org.apache.hadoop.io.serializer.WritableSerialization,org.apache.hadoop.io.serializer.avro.AvroSpecificSerialization,org.apache.hadoop.io.serializer.avro.AvroReflectSerialization</value>
   <description>A list of serialization classes that can be used for
   obtaining serializers and deserializers.</description>
 </property>

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java Thu Apr 29 18:09:56 2010
@@ -31,7 +31,6 @@ import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.Writer;
 import java.net.URL;
-import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -1048,138 +1047,6 @@ public class Configuration implements It
   }
 
   /**
-   * Instantiates a map view over a subset of the entries in
-   * the Configuration. This is instantiated by getMap(), which
-   * binds a prefix of the namespace to the ConfigItemMap. This
-   * mapping reflects changes to the underlying Configuration.
-   *
-   * This map does not support iteration.
-   */
-  protected class ConfigItemMap extends AbstractMap<String, String>
-      implements Map<String, String> {
-
-    private final String prefix;
-
-    public ConfigItemMap(String prefix) {
-      this.prefix = prefix;
-    }
-
-    @Override
-    public boolean containsKey(Object key) {
-      return lookup(key.toString()) != null;
-    }
-
-    @Override
-    public Set<Map.Entry<String, String>> entrySet() {
-      throw new UnsupportedOperationException("unsupported");
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      return o != null && o instanceof ConfigItemMap
-          && prefix.equals(((ConfigItemMap) o).prefix)
-          && Configuration.this == ((ConfigItemMap) o).getConfiguration();
-    }
-
-    private Configuration getConfiguration() {
-      return Configuration.this;
-    }
-
-    @Override
-    public String get(Object key) {
-      if (null == key) {
-        return null;
-      }
-
-      return lookup(key.toString());
-    }
-
-    @Override
-    public int hashCode() {
-      return prefix.hashCode();
-    }
-
-    @Override
-    public String put(String key, String val) {
-      if (null == key) {
-        return null;
-      }
-
-      String ret = get(key);
-      Configuration.this.set(prefix + key, val);
-      return ret;
-    }
-
-    @Override
-    public void putAll(Map<? extends String, ? extends String> m) {
-      for (Map.Entry<? extends String, ? extends String> entry : m.entrySet()) {
-        put(entry.getKey(), entry.getValue());
-      }
-    }
-
-    private String lookup(String subKey) {
-      String configKey = prefix + subKey;
-      Properties props = Configuration.this.getProps();
-      Object val = props.get(configKey);
-      String str = null;
-      if (null != val) {
-        str = substituteVars(val.toString());
-      }
-
-      return str;
-    }
-  }
-
-  /**
-   * Given a string -&gt; string map as a value, embed this in the
-   * Configuration by prepending 'name' to all the keys in the valueMap,
-   * and storing it inside the current Configuration.
-   *
-   * e.g., setMap("foo", { "bar" -&gt; "a", "baz" -&gt; "b" }) would
-   * insert "foo.bar" -&gt; "a" and "foo.baz" -&gt; "b" in this
-   * Configuration.
-   *
-   * @param name the prefix to attach to all keys in the valueMap. This
-   * should not have a trailing "." character.
-   * @param valueMap the map to embed in the Configuration.
-   */
-  public void setMap(String name, Map<String, String> valueMap) {
-    // Store all elements of the map proper.
-    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
-      set(name + "." + entry.getKey(), entry.getValue());
-    }
-  }
-
-  /**
-   * Returns a map containing a view of all configuration properties
-   * whose names begin with "name.*", with the "name." prefix  removed.
-   * e.g., if "foo.bar" -&gt; "a" and "foo.baz" -&gt; "b" are in the
-   * Configuration, getMap("foo") would return { "bar" -&gt; "a",
-   * "baz" -&gt; "b" }.
-   *
-   * Map name deprecation is handled via "prefix deprecation"; the individual
-   * keys created in a configuration by inserting a map do not need to be
-   * individually deprecated -- it is sufficient to deprecate the 'name'
-   * associated with the map and bind that to a new name. e.g., if "foo"
-   * is deprecated for "newfoo," and the configuration contains entries for
-   * "newfoo.a" and "newfoo.b", getMap("foo") will return a map containing
-   * the keys "a" and "b".
-   *
-   * The returned map does not support iteration; it is a lazy view over
-   * the slice of the configuration whose keys begin with 'name'. Updates
-   * to the underlying configuration are reflected in the returned map,
-   * and updates to the map will modify the underlying configuration.
-   *
-   * @param name The prefix of the key names to extract into the output map.
-   * @return a String-&gt;String map that contains all (k, v) pairs
-   * where 'k' begins with 'name.'; the 'name.' prefix is removed in the output.
-   */
-  public Map<String, String> getMap(String name) {
-    String prefix = handleDeprecation(name) + ".";
-    return new ConfigItemMap(prefix);
-  }
-
-  /**
    * Load a class by name.
    * 
    * @param name the class name.

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/DefaultStringifier.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/DefaultStringifier.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/DefaultStringifier.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/DefaultStringifier.java Thu Apr 29 18:09:56 2010
@@ -21,21 +21,20 @@ package org.apache.hadoop.io;
 import java.io.IOException;
 import java.nio.charset.UnsupportedCharsetException;
 import java.util.ArrayList;
-import java.util.Map;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.serializer.DeserializerBase;
-import org.apache.hadoop.io.serializer.SerializationBase;
+import org.apache.hadoop.io.serializer.Deserializer;
+import org.apache.hadoop.io.serializer.Serialization;
 import org.apache.hadoop.io.serializer.SerializationFactory;
-import org.apache.hadoop.io.serializer.SerializerBase;
+import org.apache.hadoop.io.serializer.Serializer;
 import org.apache.hadoop.util.GenericsUtil;
 
 /**
  * DefaultStringifier is the default implementation of the {@link Stringifier}
  * interface which stringifies the objects using base64 encoding of the
- * serialized version of the objects. The {@link SerializerBase} and
- * {@link DeserializerBase} are obtained from the {@link SerializationFactory}.
+ * serialized version of the objects. The {@link Serializer} and
+ * {@link Deserializer} are obtained from the {@link SerializationFactory}.
  * <br>
  * DefaultStringifier offers convenience methods to store/load objects to/from
  * the configuration.
@@ -46,9 +45,9 @@ public class DefaultStringifier<T> imple
 
   private static final String SEPARATOR = ",";
 
-  private SerializerBase<T> serializer;
+  private Serializer<T> serializer;
 
-  private DeserializerBase<T> deserializer;
+  private Deserializer<T> deserializer;
 
   private DataInputBuffer inBuf;
 
@@ -57,9 +56,8 @@ public class DefaultStringifier<T> imple
   public DefaultStringifier(Configuration conf, Class<T> c) {
 
     SerializationFactory factory = new SerializationFactory(conf);
-    Map<String, String> metadata = SerializationBase.getMetadataFromClass(c);
-    this.serializer = factory.getSerializer(metadata);
-    this.deserializer = factory.getDeserializer(metadata);
+    this.serializer = factory.getSerializer(c);
+    this.deserializer = factory.getDeserializer(c);
     this.inBuf = new DataInputBuffer();
     this.outBuf = new DataOutputBuffer();
     try {
@@ -104,7 +102,7 @@ public class DefaultStringifier<T> imple
    * @param item the object to be stored
    * @param keyName the name of the key to use
    * @throws IOException : forwards Exceptions from the underlying 
-   * {@link SerializationBase} classes. 
+   * {@link Serialization} classes. 
    */
   public static <K> void store(Configuration conf, K item, String keyName)
   throws IOException {
@@ -124,7 +122,7 @@ public class DefaultStringifier<T> imple
    * @param itemClass the class of the item
    * @return restored object
    * @throws IOException : forwards Exceptions from the underlying 
-   * {@link SerializationBase} classes.
+   * {@link Serialization} classes.
    */
   public static <K> K load(Configuration conf, String keyName,
       Class<K> itemClass) throws IOException {
@@ -147,7 +145,7 @@ public class DefaultStringifier<T> imple
    * @param keyName the name of the key to use
    * @throws IndexOutOfBoundsException if the items array is empty
    * @throws IOException : forwards Exceptions from the underlying 
-   * {@link SerializationBase} classes.         
+   * {@link Serialization} classes.         
    */
   public static <K> void storeArray(Configuration conf, K[] items,
       String keyName) throws IOException {
@@ -175,7 +173,7 @@ public class DefaultStringifier<T> imple
    * @param itemClass the class of the item
    * @return restored object
    * @throws IOException : forwards Exceptions from the underlying 
-   * {@link SerializationBase} classes.
+   * {@link Serialization} classes.
    */
   public static <K> K[] loadArray(Configuration conf, String keyName,
       Class<K> itemClass) throws IOException {

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/SequenceFile.java Thu Apr 29 18:09:56 2010
@@ -33,9 +33,8 @@ import org.apache.hadoop.io.compress.Dec
 import org.apache.hadoop.io.compress.DefaultCodec;
 import org.apache.hadoop.io.compress.GzipCodec;
 import org.apache.hadoop.io.compress.zlib.ZlibFactory;
-import org.apache.hadoop.io.serializer.DeserializerBase;
-import org.apache.hadoop.io.serializer.SerializationBase;
-import org.apache.hadoop.io.serializer.SerializerBase;
+import org.apache.hadoop.io.serializer.Deserializer;
+import org.apache.hadoop.io.serializer.Serializer;
 import org.apache.hadoop.io.serializer.SerializationFactory;
 import org.apache.hadoop.conf.*;
 import org.apache.hadoop.util.Progressable;
@@ -706,14 +705,6 @@ public class SequenceFile {
       return new TreeMap<Text, Text>(this.theMetadata);
     }
     
-    public Map<String, String> getMetadataAsStringMap() {
-      Map<String, String> map = new HashMap<String, String>();
-      for (Map.Entry<Text, Text> entry : theMetadata.entrySet()) {
-        map.put(entry.getKey().toString(), entry.getValue().toString());
-      }
-      return map;
-    }
-    
     public void write(DataOutput out) throws IOException {
       out.writeInt(this.theMetadata.size());
       Iterator<Map.Entry<Text, Text>> iter =
@@ -810,9 +801,9 @@ public class SequenceFile {
     Metadata metadata = null;
     Compressor compressor = null;
     
-    protected SerializerBase keySerializer;
-    protected SerializerBase uncompressedValSerializer;
-    protected SerializerBase compressedValSerializer;
+    protected Serializer keySerializer;
+    protected Serializer uncompressedValSerializer;
+    protected Serializer compressedValSerializer;
     
     // Insert a globally unique 16-byte value every few entries, so that one
     // can seek into the middle of a file and then synchronize with record
@@ -923,10 +914,9 @@ public class SequenceFile {
       this.codec = codec;
       this.metadata = metadata;
       SerializationFactory serializationFactory = new SerializationFactory(conf);
-      this.keySerializer = getSerializer(serializationFactory, keyClass, metadata);
+      this.keySerializer = serializationFactory.getSerializer(keyClass);
       this.keySerializer.open(buffer);
-      this.uncompressedValSerializer = getSerializer(serializationFactory,
-        valClass, metadata);
+      this.uncompressedValSerializer = serializationFactory.getSerializer(valClass);
       this.uncompressedValSerializer.open(buffer);
       if (this.codec != null) {
         ReflectionUtils.setConf(this.codec, this.conf);
@@ -934,20 +924,11 @@ public class SequenceFile {
         this.deflateFilter = this.codec.createOutputStream(buffer, compressor);
         this.deflateOut = 
           new DataOutputStream(new BufferedOutputStream(deflateFilter));
-        this.compressedValSerializer = getSerializer(serializationFactory,
-          valClass, metadata);
+        this.compressedValSerializer = serializationFactory.getSerializer(valClass);
         this.compressedValSerializer.open(deflateOut);
       }
     }
     
-    @SuppressWarnings("unchecked")
-    private SerializerBase getSerializer(SerializationFactory sf, Class c,
-	Metadata metadata) {
-      Map<String, String> stringMetadata = metadata.getMetadataAsStringMap();
-      stringMetadata.put(SerializationBase.CLASS_KEY, c.getName());
-      return sf.getSerializer(stringMetadata);
-    }
-    
     /** Returns the class of keys in this file. */
     public Class getKeyClass() { return keyClass; }
 
@@ -1432,8 +1413,8 @@ public class SequenceFile {
     private DataInputStream valIn = null;
     private Decompressor valDecompressor = null;
     
-    private DeserializerBase keyDeserializer;
-    private DeserializerBase valDeserializer;
+    private Deserializer keyDeserializer;
+    private Deserializer valDeserializer;
 
     /**
      * Construct a reader by opening a file from the given file system.
@@ -1630,24 +1611,21 @@ public class SequenceFile {
         SerializationFactory serializationFactory =
           new SerializationFactory(conf);
         this.keyDeserializer =
-          getDeserializer(serializationFactory, getKeyClass(), metadata);
+          getDeserializer(serializationFactory, getKeyClass());
         if (!blockCompressed) {
           this.keyDeserializer.open(valBuffer);
         } else {
           this.keyDeserializer.open(keyIn);
         }
         this.valDeserializer =
-          getDeserializer(serializationFactory, getValueClass(), metadata);
+          getDeserializer(serializationFactory, getValueClass());
         this.valDeserializer.open(valIn);
       }
     }
     
     @SuppressWarnings("unchecked")
-    private DeserializerBase getDeserializer(SerializationFactory sf, Class c,
-	Metadata metadata) {
-      Map<String, String> stringMetadata = metadata.getMetadataAsStringMap();
-      stringMetadata.put(SerializationBase.CLASS_KEY, c.getName());
-      return sf.getDeserializer(stringMetadata);
+    private Deserializer getDeserializer(SerializationFactory sf, Class c) {
+      return sf.getDeserializer(c);
     }
     
     /** Close the file. */

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Deserializer.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Deserializer.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Deserializer.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Deserializer.java Thu Apr 29 18:09:56 2010
@@ -34,7 +34,6 @@ import java.io.InputStream;
  * </p>
  * @param <T>
  */
-@Deprecated
 public interface Deserializer<T> {
   /**
    * <p>Prepare the deserializer for reading.</p>

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/DeserializerComparator.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/DeserializerComparator.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/DeserializerComparator.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/DeserializerComparator.java Thu Apr 29 18:09:56 2010
@@ -52,13 +52,6 @@ public abstract class DeserializerCompar
     this.deserializer.open(buffer);
   }
 
-  protected DeserializerComparator(DeserializerBase<T> deserializer)
-    throws IOException {
-    
-    this.deserializer = deserializer;
-    this.deserializer.open(buffer);
-  }
-
   public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
     try {
       

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/JavaSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/JavaSerialization.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/JavaSerialization.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/JavaSerialization.java Thu Apr 29 18:09:56 2010
@@ -34,10 +34,10 @@ import org.apache.hadoop.io.RawComparato
  * </p>
  * @see JavaSerializationComparator
  */
-public class JavaSerialization extends SerializationBase<Serializable> {
+public class JavaSerialization implements Serialization<Serializable> {
 
   static class JavaSerializationDeserializer<T extends Serializable>
-    extends DeserializerBase<T> {
+    implements Deserializer<T> {
 
     private ObjectInputStream ois;
 
@@ -65,15 +65,10 @@ public class JavaSerialization extends S
 
   }
 
-  static class JavaSerializationSerializer<T extends Serializable>
-      extends SerializerBase<T> {
+  static class JavaSerializationSerializer
+    implements Serializer<Serializable> {
 
     private ObjectOutputStream oos;
-    private Map<String, String> metadata;
-
-    public JavaSerializationSerializer(Map<String, String> metadata) {
-      this.metadata = metadata;
-    }
 
     public void open(OutputStream out) throws IOException {
       oos = new ObjectOutputStream(out) {
@@ -83,7 +78,7 @@ public class JavaSerialization extends S
       };
     }
 
-    public void serialize(T object) throws IOException {
+    public void serialize(Serializable object) throws IOException {
       oos.reset(); // clear (class) back-references
       oos.writeObject(object);
     }
@@ -92,53 +87,18 @@ public class JavaSerialization extends S
       oos.close();
     }
 
-    @Override
-    public Map<String, String> getMetadata() throws IOException {
-      return metadata;
-    }
   }
 
-  public boolean accept(Map<String, String> metadata) {
-    if (!checkSerializationKey(metadata)) {
-      return false;
-    }
-
-    Class<?> c = getClassFromMetadata(metadata);
+  public boolean accept(Class<?> c) {
     return Serializable.class.isAssignableFrom(c);
   }
 
-  public DeserializerBase<Serializable> getDeserializer(
-      Map<String, String> metadata) {
+  public Deserializer<Serializable> getDeserializer(Class<Serializable> c) {
     return new JavaSerializationDeserializer<Serializable>();
   }
 
-  public SerializerBase<Serializable> getSerializer(
-      Map<String, String> metadata) {
-    return new JavaSerializationSerializer<Serializable>(metadata);
+  public Serializer<Serializable> getSerializer(Class<Serializable> c) {
+    return new JavaSerializationSerializer();
   }
 
-  @SuppressWarnings("unchecked")
-  @Override
-  public RawComparator<Serializable> getRawComparator(
-      Map<String, String> metadata) {
-    Class<?> klazz = getClassFromMetadata(metadata);
-    if (null == klazz) {
-      throw new IllegalArgumentException(
-          "Cannot get comparator without " + SerializationBase.CLASS_KEY
-          + " set in metadata");
-    }
-
-    if (Serializable.class.isAssignableFrom(klazz)) {
-      try {
-        return (RawComparator<Serializable>) new JavaSerializationComparator();
-      } catch (IOException ioe) {
-        throw new IllegalArgumentException(
-            "Could not instantiate JavaSerializationComparator for type "
-            + klazz.getName(), ioe);
-      }
-    } else {
-      throw new IllegalArgumentException("Class " + klazz.getName()
-          + " is incompatible with JavaSerialization");
-    }
-  }
 }

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Serialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Serialization.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Serialization.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/Serialization.java Thu Apr 29 18:09:56 2010
@@ -24,7 +24,6 @@ package org.apache.hadoop.io.serializer;
  * </p>
  * @param <T>
  */
-@Deprecated
 public interface Serialization<T> {
   
   /**

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/SerializationFactory.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/SerializationFactory.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/SerializationFactory.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/SerializationFactory.java Thu Apr 29 18:09:56 2010
@@ -20,13 +20,11 @@ package org.apache.hadoop.io.serializer;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
-import org.apache.hadoop.io.serializer.avro.AvroGenericSerialization;
 import org.apache.hadoop.io.serializer.avro.AvroReflectSerialization;
 import org.apache.hadoop.io.serializer.avro.AvroSpecificSerialization;
 import org.apache.hadoop.util.ReflectionUtils;
@@ -34,7 +32,7 @@ import org.apache.hadoop.util.StringUtil
 
 /**
  * <p>
- * A factory for {@link SerializationBase}s.
+ * A factory for {@link Serialization}s.
  * </p>
  */
 public class SerializationFactory extends Configured {
@@ -42,10 +40,7 @@ public class SerializationFactory extend
   private static final Log LOG =
     LogFactory.getLog(SerializationFactory.class.getName());
 
-  private List<SerializationBase<?>> serializations =
-    new ArrayList<SerializationBase<?>>();
-  private List<SerializationBase<?>> legacySerializations =
-    new ArrayList<SerializationBase<?>>();
+  private List<Serialization<?>> serializations = new ArrayList<Serialization<?>>();
   
   /**
    * <p>
@@ -59,8 +54,7 @@ public class SerializationFactory extend
     for (String serializerName : conf.getStrings("io.serializations", 
       new String[]{WritableSerialization.class.getName(), 
         AvroSpecificSerialization.class.getName(), 
-        AvroReflectSerialization.class.getName(),
-        AvroGenericSerialization.class.getName()})) {
+        AvroReflectSerialization.class.getName()})) {
       add(conf, serializerName);
     }
   }
@@ -68,64 +62,32 @@ public class SerializationFactory extend
   @SuppressWarnings("unchecked")
   private void add(Configuration conf, String serializationName) {
     try {
-      Class<?> serializationClass = conf.getClassByName(serializationName);
-      if (SerializationBase.class.isAssignableFrom(serializationClass)) {
-	serializations.add((SerializationBase)
-	    ReflectionUtils.newInstance(serializationClass, getConf()));	
-      } else if (Serialization.class.isAssignableFrom(serializationClass)) {
-	Serialization serialization = (Serialization)
-	    ReflectionUtils.newInstance(serializationClass, getConf());
-	legacySerializations.add(new LegacySerialization(serialization,
-	    getConf()));	
-      } else {
-	LOG.warn("Serialization class " + serializationName + " is not an " +
-			"instance of Serialization or BaseSerialization.");
-      }
+      Class<? extends Serialization> serializionClass =
+	(Class<? extends Serialization>) conf.getClassByName(serializationName);
+      serializations.add((Serialization)
+	  ReflectionUtils.newInstance(serializionClass, getConf()));
     } catch (ClassNotFoundException e) {
       LOG.warn("Serialization class not found: " +
           StringUtils.stringifyException(e));
     }
   }
 
-  @Deprecated
   public <T> Serializer<T> getSerializer(Class<T> c) {
     return getSerialization(c).getSerializer(c);
   }
 
-  @Deprecated
   public <T> Deserializer<T> getDeserializer(Class<T> c) {
     return getSerialization(c).getDeserializer(c);
   }
 
-  @Deprecated
-  public <T> Serialization<T> getSerialization(Class<T> c) {
-    return getSerialization(SerializationBase.getMetadataFromClass(c));
-  }
-  
-  public <T> SerializerBase<T> getSerializer(Map<String, String> metadata) {
-    SerializationBase<T> serialization = getSerialization(metadata);
-    return serialization.getSerializer(metadata);
-  }
-    
-  public <T> DeserializerBase<T> getDeserializer(Map<String, String> metadata) {
-    SerializationBase<T> serialization = getSerialization(metadata);
-    return serialization.getDeserializer(metadata);
-  }
-    
   @SuppressWarnings("unchecked")
-  public <T> SerializationBase<T> getSerialization(Map<String, String> metadata) {
-    for (SerializationBase serialization : serializations) {
-      if (serialization.accept(metadata)) {
-        return (SerializationBase<T>) serialization;
-      }
-    }
-    // Look in the legacy serializations last, since they ignore
-    // non-class metadata
-    for (SerializationBase serialization : legacySerializations) {
-      if (serialization.accept(metadata)) {
-        return (SerializationBase<T>) serialization;
+  public <T> Serialization<T> getSerialization(Class<T> c) {
+    for (Serialization serialization : serializations) {
+      if (serialization.accept(c)) {
+	return (Serialization<T>) serialization;
       }
     }
     return null;
   }
+  
 }

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/WritableSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/WritableSerialization.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/WritableSerialization.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/WritableSerialization.java Thu Apr 29 18:09:56 2010
@@ -26,20 +26,19 @@ import java.io.OutputStream;
 import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.RawComparator;
+import org.apache.hadoop.conf.Configured;
 import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-import org.apache.hadoop.io.WritableComparator;
 import org.apache.hadoop.util.ReflectionUtils;
-import org.apache.hadoop.util.StringUtils;
 
 /**
- * A {@link SerializationBase} for {@link Writable}s that delegates to
+ * A {@link Serialization} for {@link Writable}s that delegates to
  * {@link Writable#write(java.io.DataOutput)} and
  * {@link Writable#readFields(java.io.DataInput)}.
  */
-public class WritableSerialization extends SerializationBase<Writable> {
-  static class WritableDeserializer extends DeserializerBase<Writable> {
+public class WritableSerialization extends Configured
+	implements Serialization<Writable> {
+  static class WritableDeserializer extends Configured
+  	implements Deserializer<Writable> {
 
     private Class<?> writableClass;
     private DataInputStream dataIn;
@@ -78,30 +77,10 @@ public class WritableSerialization exten
     
   }
   
-  static class WritableSerializer extends SerializerBase<Writable> {
+  static class WritableSerializer extends Configured implements
+  	Serializer<Writable> {
     
-    private Map<String, String> metadata;
     private DataOutputStream dataOut;
-    private Class<?> serializedClass;
-    
-    public WritableSerializer(Configuration conf,
-        Map<String, String> metadata) {
-      this.metadata = metadata;
-
-      // If this metadata specifies a serialized class, memoize the
-      // class object for this.
-      String className = this.metadata.get(CLASS_KEY);
-      if (null != className) {
-        try {
-          this.serializedClass = conf.getClassByName(className);
-        } catch (ClassNotFoundException cnfe) {
-          throw new RuntimeException(cnfe);
-        }
-      } else {
-        throw new UnsupportedOperationException("the "
-            + CLASS_KEY + " metadata is missing, but is required.");
-      }
-    }
     
     @Override
     public void open(OutputStream out) {
@@ -114,10 +93,6 @@ public class WritableSerialization exten
 
     @Override
     public void serialize(Writable w) throws IOException {
-      if (serializedClass != w.getClass()) {
-        throw new IOException("Type mismatch in serialization: expected "
-            + serializedClass + "; received " + w.getClass());
-      }
       w.write(dataOut);
     }
 
@@ -126,45 +101,21 @@ public class WritableSerialization exten
       dataOut.close();
     }
 
-    @Override
-    public Map<String, String> getMetadata() throws IOException {
-      return metadata;
-    }
-
   }
 
   @Override
-  public boolean accept(Map<String, String> metadata) {
-    if (!checkSerializationKey(metadata)) {
-      return false;
-    }
-
-    Class<?> c = getClassFromMetadata(metadata);
-    return c == null ? false : Writable.class.isAssignableFrom(c);
+  public boolean accept(Class<?> c) {
+    return Writable.class.isAssignableFrom(c);
   }
 
   @Override
-  public SerializerBase<Writable> getSerializer(Map<String, String> metadata) {
-    return new WritableSerializer(getConf(), metadata);
+  public Serializer<Writable> getSerializer(Class<Writable> c) {
+    return new WritableSerializer();
   }
   
   @Override
-  public DeserializerBase<Writable> getDeserializer(Map<String, String> metadata) {
-    Class<?> c = getClassFromMetadata(metadata);
+  public Deserializer<Writable> getDeserializer(Class<Writable> c) {
     return new WritableDeserializer(getConf(), c);
   }
 
-  @Override
-  @SuppressWarnings("unchecked")
-  public RawComparator<Writable> getRawComparator(Map<String, String> metadata) {
-    Class<?> klazz = getClassFromMetadata(metadata);
-    if (null == klazz) {
-      throw new IllegalArgumentException(
-          "Cannot get comparator without " + SerializationBase.CLASS_KEY
-          + " set in metadata");
-    }
-
-    return (RawComparator) WritableComparator.get(
-        (Class<WritableComparable>)klazz);
-  }
 }

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroReflectSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroReflectSerialization.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroReflectSerialization.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroReflectSerialization.java Thu Apr 29 18:09:56 2010
@@ -19,7 +19,6 @@
 package org.apache.hadoop.io.serializer.avro;
 
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.avro.Schema;
@@ -28,7 +27,6 @@ import org.apache.avro.io.DatumWriter;
 import org.apache.avro.reflect.ReflectData;
 import org.apache.avro.reflect.ReflectDatumReader;
 import org.apache.avro.reflect.ReflectDatumWriter;
-import org.apache.avro.specific.SpecificRecord;
 
 /**
  * Serialization for Avro Reflect classes. For a class to be accepted by this 
@@ -50,17 +48,10 @@ public class AvroReflectSerialization ex
   private Set<String> packages; 
 
   @Override
-  public synchronized boolean accept(Map<String, String> metadata) {
+  public synchronized boolean accept(Class<?> c) {
     if (packages == null) {
       getPackages();
     }
-    if (!checkSerializationKey(metadata)) {
-      return false;
-    }
-    Class<?> c = getClassFromMetadata(metadata);
-    if (c == null) {
-      return false;
-    }
     return AvroReflectSerializable.class.isAssignableFrom(c) || 
       packages.contains(c.getPackage().getName());
   }
@@ -76,22 +67,21 @@ public class AvroReflectSerialization ex
   }
 
   @Override
-  public DatumReader getReader(Map<String, String> metadata) {
+  public DatumReader getReader(Class<Object> clazz) {
     try {
-      return new ReflectDatumReader(getClassFromMetadata(metadata));
+      return new ReflectDatumReader(clazz);
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
   }
 
   @Override
-  public Schema getSchema(Map<String, String> metadata) {
-    Class<?> c = getClassFromMetadata(metadata);
-    return ReflectData.get().getSchema(c);
+  public Schema getSchema(Object t) {
+    return ReflectData.get().getSchema(t.getClass());
   }
 
   @Override
-  public DatumWriter getWriter(Map<String, String> metadata) {
+  public DatumWriter getWriter(Class<Object> clazz) {
     return new ReflectDatumWriter();
   }
 

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSerialization.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSerialization.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSerialization.java Thu Apr 29 18:09:56 2010
@@ -21,62 +21,57 @@ package org.apache.hadoop.io.serializer.
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.Map;
 
 import org.apache.avro.Schema;
-import org.apache.avro.io.DecoderFactory;
 import org.apache.avro.io.BinaryDecoder;
 import org.apache.avro.io.BinaryEncoder;
 import org.apache.avro.io.DatumReader;
 import org.apache.avro.io.DatumWriter;
-import org.apache.hadoop.io.RawComparator;
-import org.apache.hadoop.io.serializer.DeserializerBase;
-import org.apache.hadoop.io.serializer.SerializationBase;
-import org.apache.hadoop.io.serializer.SerializerBase;
+import org.apache.avro.io.DecoderFactory;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.io.serializer.Deserializer;
+import org.apache.hadoop.io.serializer.Serialization;
+import org.apache.hadoop.io.serializer.Serializer;
 
 /**
  * Base class for providing serialization to Avro types.
  */
-public abstract class AvroSerialization<T> extends SerializationBase<T> {
+public abstract class AvroSerialization<T> extends Configured 
+	implements Serialization<T>{
   
   public static final String AVRO_SCHEMA_KEY = "Avro-Schema";
 
-  public DeserializerBase<T> getDeserializer(Map<String, String> metadata) {
-    return new AvroDeserializer(metadata);
+  public Deserializer<T> getDeserializer(Class<T> c) {
+    return new AvroDeserializer(c);
   }
 
-  public SerializerBase<T> getSerializer(Map<String, String> metadata) {
-    return new AvroSerializer(metadata);
+  public Serializer<T> getSerializer(Class<T> c) {
+    return new AvroSerializer(c);
   }
 
   /**
-   * Return an Avro Schema instance for the given class and metadata.
+   * Return an Avro Schema instance for the given class.
    */
-  public abstract Schema getSchema(Map<String, String> metadata);
+  public abstract Schema getSchema(T t);
 
   /**
-   * Create and return Avro DatumWriter for the given metadata.
+   * Create and return Avro DatumWriter for the given class.
    */
-  public abstract DatumWriter<T> getWriter(Map<String, String> metadata);
+  public abstract DatumWriter<T> getWriter(Class<T> clazz);
 
   /**
-   * Create and return Avro DatumReader for the given metadata.
+   * Create and return Avro DatumReader for the given class.
    */
-  public abstract DatumReader<T> getReader(Map<String, String> metadata);
+  public abstract DatumReader<T> getReader(Class<T> clazz);
 
-  class AvroSerializer extends SerializerBase<T> {
+  class AvroSerializer implements Serializer<T> {
 
-    private Map<String, String> metadata;
     private DatumWriter<T> writer;
     private BinaryEncoder encoder;
     private OutputStream outStream;
-    private Schema schema;
 
-    AvroSerializer(Map<String, String> metadata) {
-      this.metadata = metadata;
-      this.writer = getWriter(metadata);
-      this.schema = getSchema(this.metadata);
-      writer.setSchema(this.schema);
+    AvroSerializer(Class<T> clazz) {
+      this.writer = getWriter(clazz);
     }
 
     @Override
@@ -93,24 +88,20 @@ public abstract class AvroSerialization<
 
     @Override
     public void serialize(T t) throws IOException {
+      writer.setSchema(getSchema(t));
       writer.write(t, encoder);
     }
 
-    @Override
-    public Map<String, String> getMetadata() throws IOException {
-      return metadata;
-    }
-
   }
 
-  class AvroDeserializer extends DeserializerBase<T> {
+  class AvroDeserializer implements Deserializer<T> {
 
     private DatumReader<T> reader;
     private BinaryDecoder decoder;
     private InputStream inStream;
 
-    AvroDeserializer(Map<String, String> metadata) {
-      this.reader = getReader(metadata);
+    AvroDeserializer(Class<T> clazz) {
+      this.reader = getReader(clazz);
     }
 
     @Override
@@ -131,18 +122,4 @@ public abstract class AvroSerialization<
 
   }
 
-  @Override
-  @SuppressWarnings("unchecked")
-  /**
-   * Provides a raw comparator for Avro-encoded serialized data.
-   * Requires that {@link AvroSerialization#AVRO_SCHEMA_KEY} be provided
-   * in the metadata argument.
-   * @param metadata the Avro-serialization-specific parameters being
-   * provided that detail the schema for the data to deserialize and compare.
-   * @return a RawComparator parameterized for the specified Avro schema.
-   */
-  public RawComparator<T> getRawComparator(Map<String, String> metadata) {
-    Schema schema = getSchema(metadata);
-    return new AvroComparator(schema);
-  }
 }

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSpecificSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSpecificSerialization.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSpecificSerialization.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/serializer/avro/AvroSpecificSerialization.java Thu Apr 29 18:09:56 2010
@@ -18,13 +18,9 @@
 
 package org.apache.hadoop.io.serializer.avro;
 
-import java.util.Map;
-
 import org.apache.avro.Schema;
-import org.apache.avro.generic.GenericDatumReader;
 import org.apache.avro.io.DatumReader;
 import org.apache.avro.io.DatumWriter;
-import org.apache.avro.specific.SpecificData;
 import org.apache.avro.specific.SpecificDatumReader;
 import org.apache.avro.specific.SpecificDatumWriter;
 import org.apache.avro.specific.SpecificRecord;
@@ -38,31 +34,26 @@ public class AvroSpecificSerialization 
                           extends AvroSerialization<SpecificRecord>{
 
   @Override
-  public boolean accept(Map<String, String> metadata) {
-    if (!checkSerializationKey(metadata)) {
-      return false;
-    }
-    Class<?> c = getClassFromMetadata(metadata);
-    return c == null ? false : SpecificRecord.class.isAssignableFrom(c);
+  public boolean accept(Class<?> c) {
+    return SpecificRecord.class.isAssignableFrom(c);
   }
 
   @Override
-  public DatumReader getReader(Map<String, String> metadata) {
+  public DatumReader getReader(Class<SpecificRecord> clazz) {
     try {
-      return new SpecificDatumReader(getClassFromMetadata(metadata));
+      return new SpecificDatumReader(clazz.newInstance().getSchema());
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
   }
 
   @Override
-  public Schema getSchema(Map<String, String> metadata) {
-    Class<?> c = getClassFromMetadata(metadata);
-    return SpecificData.get().getSchema(c);
+  public Schema getSchema(SpecificRecord t) {
+    return t.getSchema();
   }
 
   @Override
-  public DatumWriter getWriter(Map<String, String> metadata) {
+  public DatumWriter getWriter(Class<SpecificRecord> clazz) {
     return new SpecificDatumWriter();
   }
 

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/util/ReflectionUtils.java Thu Apr 29 18:09:56 2010
@@ -35,10 +35,9 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.io.DataInputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.serializer.DeserializerBase;
-import org.apache.hadoop.io.serializer.SerializationBase;
+import org.apache.hadoop.io.serializer.Deserializer;
 import org.apache.hadoop.io.serializer.SerializationFactory;
-import org.apache.hadoop.io.serializer.SerializerBase;
+import org.apache.hadoop.io.serializer.Serializer;
 
 /**
  * General reflection utils
@@ -275,12 +274,11 @@ public class ReflectionUtils {
     buffer.outBuffer.reset();
     SerializationFactory factory = getFactory(conf);
     Class<T> cls = (Class<T>) src.getClass();
-    Map<String, String> metadata = SerializationBase.getMetadataFromClass(cls);
-    SerializerBase<T> serializer = factory.getSerializer(metadata);
+    Serializer<T> serializer = factory.getSerializer(cls);
     serializer.open(buffer.outBuffer);
     serializer.serialize(src);
     buffer.moveData();
-    DeserializerBase<T> deserializer = factory.getDeserializer(metadata);
+    Deserializer<T> deserializer = factory.getDeserializer(cls);
     deserializer.open(buffer.inBuffer);
     dst = deserializer.deserialize(dst);
     return dst;

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java Thu Apr 29 18:09:56 2010
@@ -24,7 +24,6 @@ import java.io.IOException;
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Map;
 import java.util.Random;
 import java.util.regex.Pattern;
 
@@ -366,49 +365,6 @@ public class TestConfiguration extends T
     assertTrue(fail);
   }
 
-  public void testMap() throws IOException {
-    Configuration conf = new Configuration();
-
-    // manually create a map in the config; extract
-    // its values as a map object.
-    conf.set("foo.bar", "A");
-    conf.set("foo.baz", "B");
-    assertEquals("A", conf.get("foo.bar"));
-    assertEquals("B", conf.get("foo.baz"));
-
-    Map<String, String> out = conf.getMap("foo");
-    assertEquals("A", out.get("bar"));
-    assertEquals("B", out.get("baz"));
-
-    Map<String, String> in = new HashMap<String, String>();
-    in.put("yak", "123");
-    in.put("bop", "456");
-    conf.setMap("quux", in);
-
-    // Assert that we can extract individual entries in
-    // the nested map ok.
-    assertEquals("123", conf.get("quux.yak"));
-
-    // Assert that we can get the whole map back out again.
-    out = conf.getMap("quux");
-    assertEquals("123", out.get("yak"));
-    assertEquals("456", out.get("bop"));
-
-    // Test that substitution is handled by getMap().
-    conf.set("subparam", "foo");
-    conf.set("mymap.someprop", "AAA${subparam}BBB");
-    out = conf.getMap("mymap");
-    assertEquals("AAAfooBBB", out.get("someprop"));
-
-    // Test deprecation of maps.
-    Configuration.addDeprecation("oldfoo", new String[]{"newfoo"});
-    conf.set("newfoo.a", "A");
-    conf.set("newfoo.b", "B");
-    out = conf.getMap("oldfoo");
-    assertEquals("A", out.get("a"));
-    assertEquals("B", out.get("b"));
-  }
-
   public void testPattern() throws IOException {
     out = new BufferedWriter(new FileWriter(CONFIG));
     startConfig();

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/SerializationTestUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/SerializationTestUtil.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/SerializationTestUtil.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/SerializationTestUtil.java Thu Apr 29 18:09:56 2010
@@ -17,45 +17,29 @@
  */
 package org.apache.hadoop.io.serializer;
 
-import java.util.Map;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.DataInputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.util.GenericsUtil;
 
 public class SerializationTestUtil {
-
-  /**
-   * A utility that tests serialization/deserialization. 
-   * @param <K> the class of the item
-   * @param conf configuration to use, "io.serializations" is read to 
-   * determine the serialization
-   * @param before item to (de)serialize
-   * @return deserialized item
-   */
-  public static<K> K testSerialization(Configuration conf, K before) 
-      throws Exception {
-    Map<String, String> metadata =
-      SerializationBase.getMetadataFromClass(GenericsUtil.getClass(before));
-    return testSerialization(conf, metadata, before);
-  }
   
   /**
    * A utility that tests serialization/deserialization. 
    * @param conf configuration to use, "io.serializations" is read to 
    * determine the serialization
-   * @param metadata the metadata to pass to the serializer/deserializer
    * @param <K> the class of the item
    * @param before item to (de)serialize
    * @return deserialized item
    */
-  public static <K> K testSerialization(Configuration conf, 
-      Map<String, String> metadata, K before) throws Exception {
+  public static <K> K testSerialization(Configuration conf, K before)
+  	throws Exception {
 
     SerializationFactory factory = new SerializationFactory(conf);
-    SerializerBase<K> serializer = factory.getSerializer(metadata);
-    DeserializerBase<K> deserializer = factory.getDeserializer(metadata);
+    Serializer<K> serializer 
+      = factory.getSerializer(GenericsUtil.getClass(before));
+    Deserializer<K> deserializer 
+      = factory.getDeserializer(GenericsUtil.getClass(before));
 
     DataOutputBuffer out = new DataOutputBuffer();
     serializer.open(out);

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/TestWritableSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/TestWritableSerialization.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/TestWritableSerialization.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/TestWritableSerialization.java Thu Apr 29 18:09:56 2010
@@ -22,22 +22,10 @@ import static org.apache.hadoop.io.TestG
 import static org.apache.hadoop.io.TestGenericWritable.CONF_TEST_VALUE;
 import junit.framework.TestCase;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.DataOutputBuffer;
-import org.apache.hadoop.io.RawComparator;
 import org.apache.hadoop.io.Text;
-import org.apache.hadoop.io.TestGenericWritable.Foo;
-import org.apache.hadoop.io.TestGenericWritable.Bar;
 import org.apache.hadoop.io.TestGenericWritable.Baz;
 import org.apache.hadoop.io.TestGenericWritable.FooGenericWritable;
-import org.apache.hadoop.io.serializer.DeserializerBase;
-import org.apache.hadoop.io.serializer.SerializationBase;
-import org.apache.hadoop.io.serializer.SerializerBase;
-import org.apache.hadoop.util.GenericsUtil;
 
 public class TestWritableSerialization extends TestCase {
 
@@ -49,7 +37,6 @@ public class TestWritableSerialization e
     assertEquals(before, after);
   }
   
-  
   public void testWritableConfigurable() throws Exception {
     
     //set the configuration parameter
@@ -65,118 +52,4 @@ public class TestWritableSerialization e
     assertEquals(baz, result);
     assertNotNull(result.getConf());
   }
-
-  @SuppressWarnings("unchecked")
-  public void testIgnoreMisconfiguredMetadata() throws IOException {
-    // If SERIALIZATION_KEY is set, still need class name.
-
-    Configuration conf = new Configuration();
-    Map<String, String> metadata = new HashMap<String, String>();
-    metadata.put(SerializationBase.SERIALIZATION_KEY,
-        WritableSerialization.class.getName());
-    SerializationFactory factory = new SerializationFactory(conf);
-    SerializationBase serialization = factory.getSerialization(metadata);
-    assertNull("Got serializer without any class info", serialization);
-
-    metadata.put(SerializationBase.CLASS_KEY,
-        Text.class.getName());
-    serialization = factory.getSerialization(metadata);
-    assertNotNull("Didn't get serialization!", serialization);
-    assertTrue("Wrong serialization class",
-        serialization instanceof WritableSerialization);
-  }
-
-  @SuppressWarnings("unchecked")
-  public void testReuseSerializer() throws IOException {
-    // Test that we can write multiple objects of the same type
-    // through the same serializer.
-
-    DataOutputBuffer out = new DataOutputBuffer();
-    SerializationFactory factory = new SerializationFactory(
-        new Configuration());
-
-    // Create a few Foo objects and serialize them.
-    Foo foo = new Foo();
-    Foo foo2 = new Foo();
-    Map<String, String> metadata = SerializationBase.getMetadataFromClass(
-        GenericsUtil.getClass(foo));
-
-    SerializerBase fooSerializer = factory.getSerializer(metadata);
-    fooSerializer.open(out);
-    fooSerializer.serialize(foo);
-    fooSerializer.serialize(foo2);
-    fooSerializer.close();
-
-    out.reset();
-
-    // Create a new serializer for Bar objects
-    Bar bar = new Bar();
-    Baz baz = new Baz(); // Baz inherits from Bar.
-    metadata = SerializationBase.getMetadataFromClass(
-        GenericsUtil.getClass(bar));
-    // Check that we can serialize Bar objects.
-    SerializerBase barSerializer = factory.getSerializer(metadata);
-    barSerializer.open(out);
-    barSerializer.serialize(bar); // this should work.
-    try {
-      // This should not work. We should not allow subtype serialization.
-      barSerializer.serialize(baz);
-      fail("Expected IOException serializing baz via bar serializer.");
-    } catch (IOException ioe) {
-      // Expected.
-    }
-
-    try {
-      // This should not work. Disallow unrelated type serialization.
-      barSerializer.serialize(foo);
-      fail("Expected IOException serializing foo via bar serializer.");
-    } catch (IOException ioe) {
-      // Expected.
-    }
-
-    barSerializer.close();
-    out.reset();
-  }
-
-
-  // Test the SerializationBase.checkSerializationKey() method.
-  class DummySerializationBase extends SerializationBase<Object> {
-    public boolean accept(Map<String, String> metadata) {
-      return checkSerializationKey(metadata);
-    }
-
-    public SerializerBase<Object> getSerializer(Map<String, String> metadata) {
-      return null;
-    }
-
-    public DeserializerBase<Object> getDeserializer(Map<String, String> metadata) {
-      return null;
-    }
-
-    public RawComparator<Object> getRawComparator(Map<String, String> metadata) {
-      return null;
-    }
-  }
-
-  public void testSerializationKeyCheck() {
-    DummySerializationBase dummy = new DummySerializationBase();
-    Map<String, String> metadata = new HashMap<String, String>();
-
-    assertTrue("Didn't accept empty metadata", dummy.accept(metadata));
-
-    metadata.put(SerializationBase.SERIALIZATION_KEY,
-        DummySerializationBase.class.getName());
-    assertTrue("Didn't accept valid metadata", dummy.accept(metadata));
-
-    metadata.put(SerializationBase.SERIALIZATION_KEY, "foo");
-    assertFalse("Accepted invalid metadata", dummy.accept(metadata));
-
-    try {
-      dummy.accept((Map<String, String>) null);
-      // Shouldn't get here!
-      fail("Somehow didn't actually test the method we expected");
-    } catch (NullPointerException npe) {
-      // expected this.
-    }
-  }
 }

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/avro/TestAvroSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/avro/TestAvroSerialization.java?rev=939412&r1=939411&r2=939412&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/avro/TestAvroSerialization.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/io/serializer/avro/TestAvroSerialization.java Thu Apr 29 18:09:56 2010
@@ -18,46 +18,15 @@
 
 package org.apache.hadoop.io.serializer.avro;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import junit.framework.TestCase;
 
-import org.apache.avro.util.Utf8;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.serializer.SerializationBase;
-import org.apache.hadoop.io.serializer.SerializationFactory;
 import org.apache.hadoop.io.serializer.SerializationTestUtil;
 
 public class TestAvroSerialization extends TestCase {
 
   private static final Configuration conf = new Configuration();
 
-  @SuppressWarnings("unchecked")
-  public void testIgnoreMisconfiguredMetadata() {
-    // If SERIALIZATION_KEY is set, still need class name.
-
-    Configuration conf = new Configuration();
-    Map<String, String> metadata = new HashMap<String, String>();
-    SerializationFactory factory = new SerializationFactory(conf);
-    SerializationBase serialization = null;
-
-    metadata.put(SerializationBase.SERIALIZATION_KEY,
-        AvroGenericSerialization.class.getName());
-    serialization = factory.getSerialization(metadata);
-    assertNull("Got serializer without any class info", serialization);
-
-    metadata.put(SerializationBase.SERIALIZATION_KEY,
-        AvroReflectSerialization.class.getName());
-    serialization = factory.getSerialization(metadata);
-    assertNull("Got serializer without any class info", serialization);
-
-    metadata.put(SerializationBase.SERIALIZATION_KEY,
-        AvroSpecificSerialization.class.getName());
-    serialization = factory.getSerialization(metadata);
-    assertNull("Got serializer without any class info", serialization);
-  }
-
   public void testSpecific() throws Exception {
     AvroRecord before = new AvroRecord();
     before.intField = 5;
@@ -91,16 +60,6 @@ public class TestAvroSerialization exten
     assertEquals(before, after);
   }
   
-  public void testGeneric() throws Exception {
-    Utf8 before = new Utf8("hadoop");
-    Map<String, String> metadata = new HashMap<String, String>();
-    metadata.put(SerializationBase.SERIALIZATION_KEY,
-      AvroGenericSerialization.class.getName());
-    metadata.put(AvroSerialization.AVRO_SCHEMA_KEY, "\"string\"");
-    Utf8 after = SerializationTestUtil.testSerialization(conf, metadata, before);
-    assertEquals(before, after);
-  }
-
   public static class InnerRecord {
     public int x = 7;
 



Mime
View raw message