hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 梁李印 <liyin.lian...@aliyun-inc.com>
Subject Re: setup() and cleanup() methods for mapred api.
Date Thu, 19 Dec 2013 03:50:05 GMT
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:unmeshabiju@gmail.com] 
发送时间: 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

 

 


Mime
View raw message