title: Hadoop MapReduce: using MapWritable as a key
body: <p>I want to pass a <code>Map&lt;String, String&gt;</code> from my Mapper to the Reducer.</p>
  
  <p>So the tuple I want is: <code>&lt;(Sorted)MapWritable,IntWritable&gt;</code></p>
  
  <p>Currently, this is dodged by the poor man's serialization: I create a simple <code>Text</code> object using Guava -s MapJoiner and MapSplitter classes, which produce <code>String</code> which then can be used to initialize the <code>Text</code> object to write. So I am transferring the key-value pairs in a String, which is then Splitted back.</p>
  
  <p>But I want to drop this hack.</p>
  
  <p>I know that if <code>mapred.output.key.comparator</code> is not set, then the used key class must implement <code>WritableComparable</code>. The problem is, MapWritable and SortedMapWritable lacks this interface.</p>
  
  <p>I checked the <code>WritableComparable</code> interface, but I'm a bit confused, because you have to re-invent the write-read methods (serialization), not just <code>compareTo()</code>.</p>
  
  <p>So my question: can you help me finding a WORKING example, code, guideline or any valuable info? Thanks in advance.</p>