A. Sarid A. Sarid - 1 year ago 170
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download