Package com.mapreduce

Source Code of com.mapreduce.UrlGettingMapper

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);
    }
  };
}
TOP

Related Classes of com.mapreduce.UrlGettingMapper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.