I have the following reducer:
public static class MergeRecords extends
The MapWritables that are handled by the reducer all have Text 'keys'
and contain different 'value' classes including Text, DoubleWritable,
and a custom Writable MapArrayWritable. The reduce works as expected
if each MapWritable contains both a DoubleWritable and
MapArrayWritable. The reduce fails with the following exception if
some of the MapWritables contains only a DoubleWritable value:
java.lang.IllegalArgumentException: Id 1 exists but maps to
com.realcomp.data.hadoop.record.MapArrayWritable and not
at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:168) at
Digging into the source a little I stumbled upon the fact that the
default constructor for AbstractMapWritable does not configure itself
to handle DoubleWritable as it does for all the other base Writables.
This looks like an omission to me, and If the DoubleWritable was
configured, I would probably never have noticed this problem, as there
would be only one custom class in the MapWritable.
Should I be able to reduce on MapWritables that contain different
(custom) value classes?
It appears the org.apache.hadoop.io.serialize.WritableSerialization
class reuses the first MapWritable instance for each deserialization.
This is probably a performance optimization, and explains why I am
getting the exception. Is it possible
for me to register my own serialization class that would allow me to
deserialize MapWritables with different value classes? Are there
examples of this available?
Note: I realize I am running off of a release candidate, but I thought
I would ask here first before I go through the trouble of upgrading