You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Xine Jar <xi...@googlemail.com> on 2009/07/21 20:08:24 UTC
Question on setting a new user variable with JobConf
Hallo guys,
I would like to create a variable in the JobConf in order to set its value
from the command line
and get it again in the map function.
After a bit of reading here and there I understood that I have to do the
following::
*In the class Map, before the map function I have done this:*
*public void configure(JobConf job)
{characteristic=new String(job.get(a));}
*
*In the run function I have done the following:
*public int run(String[] args) throws Exception{
......
JobConf conf = new JobConf(getConf(),TinaAverageCommandLine.class);
......
*conf.set(a,args[2]);
*
return 0;
}
*This is my main*
public static void main(String[] args) throws Exception {
int res=ToolRunner.run(new Configuration(), new
TinaAverageCommandLine(), args);
System.exit(res);
}
*Question:
**Variable "a" should be defined globally somewhere right? otherwise it
won't be recognized!!
Is there a specific file where I can define it? Or did I misunderstand?
*
Thank you for you help,
CJ
Re: Question on setting a new user variable with JobConf
Posted by Xine Jar <xi...@googlemail.com>.
Great guys,
thank you a lot it is working now.
On Wed, Jul 22, 2009 at 3:55 AM, Aaron Kimball <aa...@cloudera.com> wrote:
> And regarding your desire to set things on the command line: If your
> program implements Tool and is launched via ToolRunner, you can
> specify "-D myparam=myvalue" on the command line and it'll
> automatically put that binding in the JobConf created for the tool,
> retrieved via getConf().
>
> - Aaron
>
> On Tue, Jul 21, 2009 at 3:10 PM, Owen O'Malley<ow...@gmail.com>
> wrote:
> > Configurations, which includes JobConf's, are string to string maps.
> > Therefore, when you submit the job, you would do:
> >
> > jobConf.set("my-string", args[2]);
> >
> > and in the map:
> >
> > jobConf.get("my-string")
> >
> > of course it is better to use a static final string rather than a
> literal,
> > but it works either way.
> >
> > -- Owen
> >
>
Re: Question on setting a new user variable with JobConf
Posted by Aaron Kimball <aa...@cloudera.com>.
And regarding your desire to set things on the command line: If your
program implements Tool and is launched via ToolRunner, you can
specify "-D myparam=myvalue" on the command line and it'll
automatically put that binding in the JobConf created for the tool,
retrieved via getConf().
- Aaron
On Tue, Jul 21, 2009 at 3:10 PM, Owen O'Malley<ow...@gmail.com> wrote:
> Configurations, which includes JobConf's, are string to string maps.
> Therefore, when you submit the job, you would do:
>
> jobConf.set("my-string", args[2]);
>
> and in the map:
>
> jobConf.get("my-string")
>
> of course it is better to use a static final string rather than a literal,
> but it works either way.
>
> -- Owen
>
Re: Question on setting a new user variable with JobConf
Posted by Owen O'Malley <ow...@gmail.com>.
Configurations, which includes JobConf's, are string to string maps.
Therefore, when you submit the job, you would do:
jobConf.set("my-string", args[2]);
and in the map:
jobConf.get("my-string")
of course it is better to use a static final string rather than a literal,
but it works either way.
-- Owen