Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
MapReduce, mail # user - setup() and cleanup() methods for mapred api.


Copy link to this message
-
Re: setup() and cleanup() methods for mapred api.
unmesha sreeveni 2013-12-19, 03:55
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, 梁李印 <[EMAIL PROTECTED]> 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:[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*
>
>
>
>
>

--
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*