Created
August 27, 2012 07:57
-
-
Save anonymous/3486573 to your computer and use it in GitHub Desktop.
Data Intensive Text Processing with MapReduce #3 SecondarySort (value-to-key conversion) Mapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.moaikids.mapred.map; | |
import java.io.IOException; | |
import org.apache.hadoop.io.IntWritable; | |
import org.apache.hadoop.io.LongWritable; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.mapreduce.Mapper; | |
public class MapSecondarySortMapper extends | |
Mapper<LongWritable, Text, Text, IntWritable> { | |
static final IntWritable ONE = new IntWritable(1); | |
@Override | |
protected void map(LongWritable key, Text value, Context context) | |
throws IOException, InterruptedException { | |
// format | |
// 0:year | |
// 1:month | |
// 2:day | |
// 3:place | |
// 4:title | |
// 5:description | |
String tsv = value.toString().trim(); | |
if (tsv.isEmpty()) { | |
return; | |
} | |
String[] params = tsv.split("\t"); | |
context.write(new Text(params[3].trim() + "\t" + params[0].trim()), ONE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment