Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tp;
- 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 MyMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
- public void map(LongWritable key, Text value, Context context) throws IOException,InterruptedException {
- String line = value.toString();
- String[] columns = line.split("\t");
- try {
- columns[7].charAt(0);
- if(columns[7] != "") {
- int val = Integer.parseInt((String) (columns[31] != "" ? columns[31] : '0'));
- Text country = new Text(columns[7]);
- context.write(country, new IntWritable(val));
- }
- } catch (Exception e) {}
- /*
- StringTokenizer tokenizer = new StringTokenizer(line);
- System.out.println(tokenizer[8]);
- while (tokenizer.hasMoreTokens()) {
- word.set(tokenizer.nextToken());
- if(word.charAt(0) == 'm') {
- context.write(word, one);
- }
- }*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement