Return-Path: X-Original-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-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 B733910C8E for ; Fri, 26 Jul 2013 15:36:41 +0000 (UTC) Received: (qmail 7242 invoked by uid 500); 26 Jul 2013 15:36:33 -0000 Delivered-To: apmail-hadoop-hdfs-user-archive@hadoop.apache.org Received: (qmail 6755 invoked by uid 500); 26 Jul 2013 15:36:29 -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 6748 invoked by uid 99); 26 Jul 2013 15:36:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jul 2013 15:36:28 +0000 X-ASF-Spam-Status: No, hits=2.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of govardhan5126@gmail.com designates 74.125.82.179 as permitted sender) Received: from [74.125.82.179] (HELO mail-we0-f179.google.com) (74.125.82.179) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jul 2013 15:36:21 +0000 Received: by mail-we0-f179.google.com with SMTP id t57so1972190wes.24 for ; Fri, 26 Jul 2013 08:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=pFmuTaJsYZ9nVC/i8W5ccZQwigd1P7XsBIPL3vnPX3o=; b=dJFJ2lIcWwlk/JH7HfRHzWo3YF9RI2dQRsGLJ3ts+PL+7Ks4SoE7r/2DGFOR2l0sfX a9TNGVW0XvkkQvL/08gZZIqGdN+Xxkn0RFuQO/O5DP+Cl8q/LyjD9kxdUfi5Gi06aS2U 7FLehd0q4u0lIeryfuM4BKkwNKvTp1IG2C+bRa8kvDLBR5SirtEW8MH6GmpKyuLSlFZe OiMK4Hnsr2ET5Q4J9MqqzHLOhNlK1NT/hXg6nltMnMjHcfseWRCPwuNLO0B5gRT+13mb /ATEfRgS9bFborp4cgBy2NWROOVr20obl5uoTLfBLnde08S6MsRHUXINbnfvVbBoBaHL HTRg== MIME-Version: 1.0 X-Received: by 10.194.93.74 with SMTP id cs10mr35992793wjb.9.1374852961558; Fri, 26 Jul 2013 08:36:01 -0700 (PDT) Received: by 10.216.239.130 with HTTP; Fri, 26 Jul 2013 08:36:01 -0700 (PDT) In-Reply-To: References: Date: Fri, 26 Jul 2013 11:36:01 -0400 Message-ID: Subject: Re: Context Object in Map Reduce From: Tanniru Govardhan To: user@hadoop.apache.org, dunanimanish@gmail.com Content-Type: multipart/alternative; boundary=047d7bf0c86c64660c04e26be696 X-Virus-Checked: Checked by ClamAV on apache.org --047d7bf0c86c64660c04e26be696 Content-Type: text/plain; charset=ISO-8859-1 Thanks Manish. you are correct. I figured it out somehow. This is what i had to change. In the main class * Configuration config = new Configuration(); config.set("filename", "Syn-100n-8t-2l-2k.vars"); * *JobConf conf = new JobConf(config,Hadoop_GNTS.class);* * * In the Map class * public void configure(JobConf job) { myfilename = job.get("filename"); } * * * Thanks * * On Fri, Jul 26, 2013 at 10:56 AM, manish dunani wrote: > If u r using OutputCollector,Reporter then no need to use Context..Context > works same as OutputCollector and Reporter. > > That is used to collect mapper's pair. > > > > On Fri, Jul 26, 2013 at 8:03 PM, manish dunani wrote: > >> Can u please elaborate what is the code and what is error.?? >> >> Then it will be much better to give the answer. >> >> Regards Manish Dunani.. >> >> >> On Fri, Jul 26, 2013 at 7:07 PM, Tanniru Govardhan < >> govardhan5126@gmail.com> wrote: >> >>> Hi everyone, >>> I am trying to pass a string variable from Driver class to Mapper class. >>> I came to know that i need to use context variable for this purpose. >>> But the Mapper method i have used has a signature without context object. >>> It is not allowing to change the method signature.(reporting syntax >>> error) >>> Can anyone please suggest me what can I do regarding this? >>> I am very new to Map Reduce Programming. >>> >>> Here is the code: >>> >>> class Map extends MapReduceBase implements Mapper>> Text, IntWritable> >>> { >>> String myfilename; >>> private Text word = new Text(); >>> private IntWritable var = new IntWritable(); >>> >>> public void map(LongWritable key, Text value, *Context context,*OutputCollector output, Reporter reporter) >>> *//here is the error * >>> throws IOException >>> { >>> Configuration conf = context.getConfiguration(); >>> myfilename = conf.get("filename"); >>> -- - - -- - -- - >>> } >>> public void compute() throws Exception >>> { >>> Configuration config = new Configuration(); >>> config.set("filename", "Syn-100n-8t-2l-2k.vars"); >>> >>> JobConf conf = new JobConf(Hadoop_GNTS.class); >>> -- - - - -- - - >>> } >>> >>> Thanks >>> >>> >> >> >> -- >> MANISH DUNANI >> -THANX >> +91 9426881954,+91 8460656443 >> manishd207@gmail.com >> > > > > -- > MANISH DUNANI > -THANX > +91 9426881954,+91 8460656443 > manishd207@gmail.com > --047d7bf0c86c64660c04e26be696 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks Manish. you are correct. I figured it out somehow.<= div>This is what i had to change.

In the main clas= s
Configuration config =3D new Configuration();
config.set("filename", "Syn-100n-8t-2l-2k.vars");=A0
JobConf conf =3D new JobConf(config,Hadoop_GNTS.class)= ;

In the Map class
public void configure(JobConf job)
=A0 {
=A0 =A0myfilen= ame =3D job.get("filename");
=A0 }
=
Thanks



On Fri, Jul 26, 2013 at 10:56 AM, manish= dunani <manishd207@gmail.com> wrote:
If u r using OutputCollector,Reporter then no need to use = Context..Context works same as OutputCollector and Reporter.

=
That is used to collect mapper's <key ,value> pair.



On Fri, Jul 26, 2013 at 8:03 PM,= manish dunani <manishd207@gmail.com> wrote:
Can u please elaborate what= is the code and what is error.??

Then it will be much b= etter to give the answer.

Regards Manish Dunani..


On Fri, Jul 26, 2013 at 7:07 PM, Tanniru= Govardhan <govardhan5126@gmail.com> wrote:
Hi everyone,
I am trying to pass a string variable fro= m Driver class to Mapper class.
I came to know that i need to use= context variable for this purpose.
But the Mapper method i have = used has a signature without context object.
It is not allowing to change the method signature.(reporting syntax er= ror)=A0
Can anyone please suggest me what can I do regarding this= ?
I am very new to Map Reduce Programming.

Here is the code:

class Map<V> ext= ends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritab= le>
{
= =A0 =A0String myfilename; =A0
=A0 private Text word =3D new Text();
=A0 private IntWri= table var =3D new IntWritable();
=A0
=A0 public void ma= p(LongWritable key, Text value, Context context, OutputCollector<= Text, IntWritable> output, Reporter reporter) //here is the error=A0<= /b>
throws IOException
=
{=A0
=A0 = =A0 =A0 =A0 =A0Configuration conf =3D context.getConfiguration();
=A0 =A0 =A0 =A0 =A0 =A0 =A0myfilename =3D conf.get("filename");<= /div>
=A0 =A0 =A0 =A0 =A0 =A0 =A0-- - - -- - -- -=A0
=A0 =A0 =A0 = =A0 }
=A0public =A0void compute() throws Exception
=A0 = {
=A0Configuration = config =3D new Configuration();
=A0 =A0 =A0 config.set("filename", "Syn-100n-8t-2l-2k.v= ars");=A0
=A0<= span style=3D"white-space:pre-wrap"> =A0
=A0 =A0 JobConf = conf =3D new JobConf(Hadoop_GNTS.class);
=A0 =A0 -- - - - -- - -=A0
}

Thanks=




<= font color=3D"#888888">--
MANISH DUNANI
-THANX
+91 9426881954,+91 8460656443



--
MANISH DUNAN= I
-THANX
+91 9426881954,+91 8460656443
--047d7bf0c86c64660c04e26be696--