Return-Path: X-Original-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-mapreduce-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 0F1657D45 for ; Thu, 1 Dec 2011 19:05:34 +0000 (UTC) Received: (qmail 77101 invoked by uid 500); 1 Dec 2011 19:05:32 -0000 Delivered-To: apmail-hadoop-mapreduce-user-archive@hadoop.apache.org Received: (qmail 77065 invoked by uid 500); 1 Dec 2011 19:05:32 -0000 Mailing-List: contact mapreduce-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mapreduce-user@hadoop.apache.org Delivered-To: mailing list mapreduce-user@hadoop.apache.org Received: (qmail 77057 invoked by uid 99); 1 Dec 2011 19:05:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 19:05:32 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mapred.learn@gmail.com designates 209.85.215.176 as permitted sender) Received: from [209.85.215.176] (HELO mail-ey0-f176.google.com) (209.85.215.176) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 19:05:25 +0000 Received: by eaal12 with SMTP id l12so3468721eaa.35 for ; Thu, 01 Dec 2011 11:05:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=z3qDBm6yfS5tSc9j30xMYFax+ZNX9aebpNL/fcXH7hM=; b=WhoHjY28zX+AvH7ZWHjoFIHQEqq3/nG/3Bwat2beLXDg5Nt6bMIa6lUMn2IZGyvVaU pXnATlDFd2ecWFG7KU+8opd/sDU3NDo+I9f2n0gZEbyZVus3GvrojbZpBZ2LeOEbxHwS T7MrKUR6/kOjANVvqS3aJCaUN+XCWw2FJS0iY= MIME-Version: 1.0 Received: by 10.216.199.81 with SMTP id w59mr552223wen.22.1322766304611; Thu, 01 Dec 2011 11:05:04 -0800 (PST) Received: by 10.180.8.169 with HTTP; Thu, 1 Dec 2011 11:05:04 -0800 (PST) In-Reply-To: <12f3b19a.2dc52.133f3d4e30e.Coremail.rabbit_cheng@126.com> References: <12f3b19a.2dc52.133f3d4e30e.Coremail.rabbit_cheng@126.com> Date: Thu, 1 Dec 2011 11:05:04 -0800 Message-ID: Subject: Re: how to access a mapper counter in reducer From: Mapred Learn To: mapreduce-user@hadoop.apache.org, rabbit_cheng@126.com Content-Type: multipart/alternative; boundary=0016e6daa93ab50f4804b30c8726 X-Virus-Checked: Checked by ClamAV on apache.org --0016e6daa93ab50f4804b30c8726 Content-Type: text/plain; charset=ISO-8859-1 Hi, I have a similar query. Infact, I sent it yesterday and waiting for anybody's response who might have done it. Thanks, Anurag Tangri 2011/11/30 rabbit_cheng > I have created a counter in mapper to count something, I wanna get the > counter's value in reducer phase, the code segment is as follow: > > public class MM extends Mapper { > static enum TEST{ pt } > @Override > public void map(LongWritable key, Text values, Context context) throws > IOException, InterruptedException { > context.getCounter(TEST.pt).increment(1); > } > } > public class KMeansReducer extends Reducer { > @Override > protected void setup(Context context) throws IOException, > InterruptedException { > long ptValue=context.getCounter(MM.TEST.pt > ).getValue(); > } > } > but what I get is always 0, i.e., the value of variable ptValue is always > 0. > Does anybody know how to access a mapper counter in reducer? > > > > --0016e6daa93ab50f4804b30c8726 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi,
I have a similar query.
=A0
Infact, I sent it yesterday and waiting for anybody's response who= might have done it.
=A0
=A0
Thanks,
Anurag Tangri

2011/11/30 rabbit_cheng <rabbit_cheng@126.com>
=A0I have created a counter in mapper to count something, I wanna= get the counter's value in reducer phase, the code segment is as follo= w:

public class MM extends Mapper<LongWritable, Text, Text, Text> {<= br>=A0=A0=A0 static enum TEST{ pt }
=A0=A0=A0 @Override
=A0=A0=A0 pub= lic void map(LongWritable key, Text values, Context context) throws IOExcep= tion, InterruptedException {
=A0=A0=A0 =A0=A0=A0 context.getCounter(TEST.pt).increment(1);
=A0=A0=A0 = }
}
public class KMeansReducer extends Reducer<Text, Text, Text, T= ext> {
=A0=A0=A0 @Override
=A0=A0=A0 protected void setup(Context = context) throws IOException,=A0 InterruptedException {
=A0=A0=A0 =A0=A0=A0 long ptValue=3Dcontext.getCounter(MM.TEST.pt).getValue();
=A0=A0=A0 }
}=
but what I get is always 0, i.e., the value of variable ptValue is alwa= ys 0.
Does anybody know how to access a mapper counter in reducer?




--0016e6daa93ab50f4804b30c8726--