package com.mapreduce;
import java.util.List;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import com.commons.UrlData;
import com.digital.DigitalUrlGetter;
import com.utils.LoggerUtils;
/**
* 用于将网站地址转化为搜索地址
*
* @author jezhang
*
*/
public class UrlGettingMapper extends Mapper<Object, Text, Text, Text> {
protected void map(
Object key,
Text value,
org.apache.hadoop.mapreduce.Mapper<Object, Text, Text, Text>.Context context)
throws java.io.IOException, InterruptedException {
LoggerUtils.log(UrlGettingMapper.class.getName(), "map key:" + key
+ " value:" + value);
DigitalUrlGetter digitalUrlGetter = new DigitalUrlGetter();
List<UrlData> datas = digitalUrlGetter.getUrlData();
for (UrlData data : datas) {
Text outputKey = new Text();
outputKey.set(data.getUrlName());
Text outputValue = new Text();
outputValue.set(data.toString());
context.write(outputKey, outputValue);
}
};
}