SHARE
TWEET

Untitled

a guest Jan 18th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package tp;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.apache.hadoop.io.IntWritable;
  6. import org.apache.hadoop.io.LongWritable;
  7. import org.apache.hadoop.io.Text;
  8. import org.apache.hadoop.mapreduce.Mapper;
  9.  
  10. public class MyMapper extends Mapper<LongWritable, Text, Text, IntWritable> {  
  11.  
  12.     public void map(LongWritable key, Text value, Context context) throws IOException,InterruptedException {
  13.         String line = value.toString();
  14.         String[] columns = line.split("\t");
  15.         try {
  16.             columns[7].charAt(0);
  17.             if(columns[7] != "") {
  18.                 int val = Integer.parseInt((String) (columns[31] != "" ? columns[31] : '0'));
  19.                 Text country = new Text(columns[7]);
  20.                 context.write(country, new IntWritable(val));
  21.             }
  22.         } catch (Exception e) {}
  23.        
  24.        
  25.        
  26.         /*
  27.         StringTokenizer tokenizer = new StringTokenizer(line);
  28.         System.out.println(tokenizer[8]);
  29.         while (tokenizer.hasMoreTokens()) {
  30.             word.set(tokenizer.nextToken());
  31.             if(word.charAt(0) == 'm') {
  32.                 context.write(word, one);
  33.             }
  34.         }*/
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top