Exemple #1
0
 @Override
 public void map(String line, Pipe<CountRec> out) {
   StringTokenizer tokenizer = new StringTokenizer(line);
   while (tokenizer.hasMoreTokens()) {
     outrec.word = tokenizer.nextToken();
     outrec.count = 1;
     out.put(outrec);
   }
 }
Exemple #2
0
 @Override
 public void map(String in, Pipe<CountRec> out) {
   StringTokenizer tokenizer = new StringTokenizer(in);
   CountRec rec = new CountRec();
   while (tokenizer.hasMoreTokens()) {
     rec.word = tokenizer.nextToken();
     rec.count = 1;
     out.put(rec);
   }
 }
Exemple #3
0
    @Override
    public void reduce(Pipe<CountRec> in, Pipe<Protos.CountRec> out) {

      String word = null;
      int count = 0;
      for (CountRec rec : in) {
        if (word == null) word = rec.word;
        count += rec.count;
      }

      out.put(Protos.CountRec.newBuilder().setWord(word).setCount(count).build());
    }