With old-api (mapred.*), there are no setup() and cleanup(). But you can use
configure() and close(). Here is a sample code:

  

  public static class MapClass extends MapReduceBase

    implements Mapper<LongWritable, Text, Text, IntWritable> {

    

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

    private Text word = new Text();

    

    @Override

    public void configure(JobConf job) {

 

    }

    

    @Override

    public void map(LongWritable key, Text value, 

                    OutputCollector<Text, IntWritable> output, 

                    Reporter reporter) throws IOException {

      String line = value.toString();

      StringTokenizer itr = new StringTokenizer(line);

      while (itr.hasMoreTokens()) {

        word.set(itr.nextToken());

        output.collect(word, one);

      }

    }

    

    @Override

    public void close() throws IOException {

       

    }

  }

 

Liyin Liang

发件人: unmesha sreeveni [mailto:[email protected]] 
发送时间: 2013年12月19日 11:25
收件人: User Hadoop
主题: setup() and cleanup() methods for mapred api.

 

Is there setup() and cleanup() methods for mapred api.

 

Is there a sample code for reference

 

-- 

Thanks & Regards 

 

Unmesha Sreeveni U.B

Junior Developer

 

 

Reply via email to