Passing arguments to Hadoop mappers

后端 未结 1 1604
感动是毒
感动是毒 2021-02-01 22:25

I\'m using new Hadoop API and looking for a way to pass some parameters (few strings) to mappers.
How can I do that?

This solutions

相关标签:
1条回答
  • 2021-02-01 23:07

    In the main method set the required parameter as below or using the -D command line option while running the job.

    Configuration conf = new Configuration();
    conf.set("test", "123");
    
    Job job = new Job(conf);
    

    In the mapper/reducer get the parameter as

    Configuration conf = context.getConfiguration();
    String param = conf.get("test");
    
    0 讨论(0)
提交回复
热议问题