title: Interface as Mapper value output
body: <p>I have a mapper whose output value is set to be an interface like this:</p>
  <pre><code>public interface OutValue extends Writable {}
  </code></pre>
  <p>During mapping, I create objects with this signature and emit them:</p>
  <pre><code>public class OutRecord implements OutValue {}
  </code></pre>
  <p>My Mapper is like this:</p>
  <pre><code>public class ExampleMapper extends
      Mapper&lt;LongWritable, Text, ExampleKey, OutValue &gt; {}
  </code></pre>
  <p>However I am getting this error:</p>
  <pre><code>java.io.IOException: Type mismatch in value from map: expected OutValue, recieved OutRecord
      at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.collect(MapTask.java:850)
      at org.apache.hadoop.mapred.MapTask$NewOutputCollector.write(MapTask.java:541)
      at org.apache.hadoop.mapreduce.TaskInputOutputContext.write(TaskInputOutputContext.java:80)
  </code></pre>
  <p>So my first instinct was to try to cast it like this:</p>
  <pre><code>context.write(key, (OutValue) record);
  </code></pre>
  <p>However I still get the same error. This worked prior to me changing the mapper output type from the OutRecord class to the OutValue interface. My reason for doing so is that I have many types of OutRecord classes I'd like to emit from this mapper.</p>
  <p>Is this possible? Does OutValue have to be a class instead of an interface?</p>
  <h3>Update:</h3>
  <p>I dug through some of the source for Hadoop 0.20.205.0 and I found this:</p>
  <pre><code>public synchronized void collect(K key, V value, int partition) throws IOException {
  ...
  if (value.getClass() != valClass) {
    throw new IOException(&quot;Type mismatch in value from map: expected &quot;
                          + valClass.getName() + &quot;, recieved &quot;
                          + value.getClass().getName());
  }
  </code></pre>
  <p>So the runtime checks they are using require strict equality in the class, they do no checking for subclassing / interfaces, etc. Surely this is a common usecase, has anyone tried to do this?</p>