hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From unmesha sreeveni <unmeshab...@gmail.com>
Subject Re: setup() and cleanup() methods for mapred api.
Date Thu, 19 Dec 2013 03:55:04 GMT
Thanks for Your reply Liyin. close() get executed after each reducer right?
Are we able to capture a dynamic value in close()?


On Thu, Dec 19, 2013 at 9:20 AM, 梁李印 <liyin.liangly@aliyun-inc.com> wrote:

> 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*
>
>
>
>
>



-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*

Mime
View raw message