A. Sarid A. Sarid - 3 months ago 7x
Java Question

Swap key and value mapper hadoop

Is there any mapper class in hadoop that swaps between keys and values? Something similar to the IdentityMapper

? Just that instead of identity, it swaps between the key and value?

Note: I know that it is simple to implement it, but I am asking if there is already a built-in one.


You can use the org.apache.hadoop.mapreduce.lib.map.InverseMapper which should do what you need. It will swap the key and value.

See: InverseMapper.java and Javadocs

There's an implementation for both the mapreduce and mapred API, the above links are for the mapreduce version.