You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-user@hadoop.apache.org by Narayanan K <kn...@gmail.com> on 2011/07/30 18:32:48 UTC

Passing Arguments to Map & Reducer using Job

Hi

I am using *Job *(
http://hadoop.apache.org/common/docs/r0.20.1/api/org/apache/hadoop/mapreduce/Job.html)
to submit a MR job on Hbase.

I want to pass some values from my main() to Map and Reduce functions.

I know how to do this using a JobConf client.

*In Main*

JobConf job = new JobConf(conf, MR.class);
job.set("Key", Value);

*In Mapper/Reducer Class*

JobConf conf;
public void configure(JobConf job)
{
  conf = job;
  val = job.get("Key");
 }

I get the value in val variable that I had set in Main, in my reducer/mapper
class using the above method.

But I tried the same with Job class instead of JobConf. There isnt a set
method for Job.

How do I pass values to map/reduce classes using Job just like I was able to
do using JobConf client?

Thanks,
Narayanan

Re: Passing Arguments to Map & Reducer using Job

Posted by Narayanan K <kn...@gmail.com>.
Hi

It worked!

Thanks,
Narayanan

On Sun, Jul 31, 2011 at 6:48 AM, web service <wb...@gmail.com> wrote:

> I think you can set properties by
> job.getConfiguration().set("property","value");
> and replace the configure with the method setup();
>
> http://hadoop.apache.org/common/docs/r0.20.1/api/org/apache/hadoop/mapreduce/Mapper.html#setup%28org.apache.hadoop.mapreduce.Mapper.Context%29
>
>
>
> On Sat, Jul 30, 2011 at 9:32 AM, Narayanan K <kn...@gmail.com>wrote:
>
>> Hi
>>
>> I am using *Job *(
>> http://hadoop.apache.org/common/docs/r0.20.1/api/org/apache/hadoop/mapreduce/Job.html)
>> to submit a MR job on Hbase.
>>
>> I want to pass some values from my main() to Map and Reduce functions.
>>
>> I know how to do this using a JobConf client.
>>
>> *In Main*
>>
>> JobConf job = new JobConf(conf, MR.class);
>> job.set("Key", Value);
>>
>> *In Mapper/Reducer Class*
>>
>> JobConf conf;
>> public void configure(JobConf job)
>> {
>>   conf = job;
>>   val = job.get("Key");
>>  }
>>
>> I get the value in val variable that I had set in Main, in my
>> reducer/mapper class using the above method.
>>
>> But I tried the same with Job class instead of JobConf. There isnt a set
>> method for Job.
>>
>> How do I pass values to map/reduce classes using Job just like I was able
>> to do using JobConf client?
>>
>> Thanks,
>> Narayanan
>>
>>
>>
>

Re: Passing Arguments to Map & Reducer using Job

Posted by web service <wb...@gmail.com>.
I think you can set properties by
job.getConfiguration().set("property","value");
and replace the configure with the method setup();
http://hadoop.apache.org/common/docs/r0.20.1/api/org/apache/hadoop/mapreduce/Mapper.html#setup%28org.apache.hadoop.mapreduce.Mapper.Context%29


On Sat, Jul 30, 2011 at 9:32 AM, Narayanan K <kn...@gmail.com> wrote:

> Hi
>
> I am using *Job *(
> http://hadoop.apache.org/common/docs/r0.20.1/api/org/apache/hadoop/mapreduce/Job.html)
> to submit a MR job on Hbase.
>
> I want to pass some values from my main() to Map and Reduce functions.
>
> I know how to do this using a JobConf client.
>
> *In Main*
>
> JobConf job = new JobConf(conf, MR.class);
> job.set("Key", Value);
>
> *In Mapper/Reducer Class*
>
> JobConf conf;
> public void configure(JobConf job)
> {
>   conf = job;
>   val = job.get("Key");
>  }
>
> I get the value in val variable that I had set in Main, in my
> reducer/mapper class using the above method.
>
> But I tried the same with Job class instead of JobConf. There isnt a set
> method for Job.
>
> How do I pass values to map/reduce classes using Job just like I was able
> to do using JobConf client?
>
> Thanks,
> Narayanan
>
>
>