All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.hadoop.sample.MapClass Maven / Gradle / Ivy

There is a newer version: 0.4
Show newest version
package org.infinispan.hadoop.sample;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
import java.util.StringTokenizer;

/**
 * The mapper
 */
public class MapClass extends Mapper {

   private final static IntWritable one = new IntWritable(1);
   private Text word = new Text();

   @Override
   protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
      String line = value.toString();
      StringTokenizer itr = new StringTokenizer(line);
      while (itr.hasMoreTokens()) {
         word.set(itr.nextToken());
         context.write(word, one);
      }
   }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy