FAQ
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

Search Discussions

  • Owen O'Malley at Jul 21, 2009 at 10:09 pm
    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
  • Aaron Kimball at Jul 22, 2009 at 1:55 am
    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'Malleywrote:
    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
  • Xine Jar at Jul 22, 2009 at 8:42 am
    Great guys,
    thank you a lot it is working now.

    On Wed, Jul 22, 2009 at 3:55 AM, Aaron Kimball 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'Malleywrote:
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommon-user @
categorieshadoop
postedJul 21, '09 at 6:07p
activeJul 22, '09 at 8:42a
posts4
users3
websitehadoop.apache.org...
irc#hadoop

People

Translate

site design / logo © 2022 Grokbase