Return-Path: X-Original-To: apmail-hadoop-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8C66C10555 for ; Thu, 19 Dec 2013 03:50:54 +0000 (UTC) Received: (qmail 93444 invoked by uid 500); 19 Dec 2013 03:50:44 -0000 Delivered-To: apmail-hadoop-user-archive@hadoop.apache.org Received: (qmail 93336 invoked by uid 500); 19 Dec 2013 03:50:39 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 93327 invoked by uid 99); 19 Dec 2013 03:50:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Dec 2013 03:50:37 +0000 X-ASF-Spam-Status: No, hits=3.2 required=5.0 tests=HTML_MESSAGE,MSGID_MULTIPLE_AT,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of liyin.liangly@aliyun-inc.com designates 42.121.48.7 as permitted sender) Received: from [42.121.48.7] (HELO out548-7.mail.aliyun.com) (42.121.48.7) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Dec 2013 03:50:31 +0000 Received: from LianglyPC(mailfrom:liyin.liangly@aliyun-inc.com ip:42.120.74.245) by smtp.aliyun-inc.com(127.0.0.1); Thu, 19 Dec 2013 11:50:06 +0800 From: =?gb2312?B?wbrA7tOh?= To: References: In-Reply-To: Subject: Re: setup() and cleanup() methods for mapred api. Date: Thu, 19 Dec 2013 11:50:05 +0800 Message-ID: <00a401cefc6d$67c435f0$374ca1d0$@liangly@aliyun-inc.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00A5_01CEFCB0.75E775F0" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac78afYKs8dwU+0XRgOXK1URmy2yEwAAqFTw Content-Language: zh-cn X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------=_NextPart_000_00A5_01CEFCB0.75E775F0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable With old-api (mapred.*), there are no setup() and cleanup(). But you can = use configure() and close(). Here is a sample code: =20 public static class MapClass extends MapReduceBase implements Mapper { =20 private final static IntWritable one =3D new IntWritable(1); private Text word =3D new Text(); =20 @Override public void configure(JobConf job) { =20 } =20 @Override public void map(LongWritable key, Text value,=20 OutputCollector output,=20 Reporter reporter) throws IOException { String line =3D value.toString(); StringTokenizer itr =3D new StringTokenizer(line); while (itr.hasMoreTokens()) { word.set(itr.nextToken()); output.collect(word, one); } } =20 @Override public void close() throws IOException { =20 } } =20 Liyin Liang =B7=A2=BC=FE=C8=CB: unmesha sreeveni [mailto:unmeshabiju@gmail.com]=20 =B7=A2=CB=CD=CA=B1=BC=E4: 2013=C4=EA12=D4=C219=C8=D5 11:25 =CA=D5=BC=FE=C8=CB: User Hadoop =D6=F7=CC=E2: setup() and cleanup() methods for mapred api. =20 Is there setup() and cleanup() methods for mapred api. =20 Is there a sample code for reference =20 --=20 Thanks & Regards=20 =20 Unmesha Sreeveni U.B Junior Developer =20 =20 ------=_NextPart_000_00A5_01CEFCB0.75E775F0 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable

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 =3D = new = IntWritable(1);

    private Text = word =3D = new = Text();

   

    @Override

    public = void = configure(JobConf job) {

 

    }

   

    @Override

    public = void = map(LongWritable key, Text value,

         &= nbsp;          OutputCo= llector<Text, IntWritable> output,

         &= nbsp;          Reporter= reporter) throws = IOException {

      String line =3D = value.toString();

      StringTokenizer itr =3D = new = StringTokenizer(line);

      while = (itr.hasMoreTokens()) {

        = word.set(itr.nextToken());

        = output.collect(word, = one);

      }

    }

   

    @Override

    public = void = close() throws = IOException {

      

    }

  = }

 

Liyin Liang

=B7=A2=BC=FE=C8=CB: unmesha sreeveni = [mailto:unmeshabiju@gmail.com]
=B7=A2=CB=CD=CA=B1=BC= =E4: 2013=C4=EA12=D4=C219=C8=D5 11:25
=CA=D5=BC=FE=C8=CB: User = Hadoop
=D6=F7=CC=E2: 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

 

 

------=_NextPart_000_00A5_01CEFCB0.75E775F0--