java pass parameters to mapper

Solutions on MaxInterview for java pass parameters to mapper by the best coders in the world

showing results for - "java pass parameters to mapper"
Isidora
04 Jun 2017
1public static class MyMapper extends MapReduceBase implements Mapper<...> {
2
3    Integer myIntegerOption;
4    String myStringOption;
5
6    @Override
7    public void configure(JobConf job) {
8        super.configure(job);
9        myIntegerOption = job.getInt("myIntOption", -1); 
10        // nb: last arg is the default value if option is not set
11        myStringOption = job.get("myStringOption", "notSet");
12    }
13
14    @Override
15    public void map(... key, ... value, 
16                    OutputCollector<..> output, Reporter reporter) throws IOException {
17        // here you can use the options in your processing
18        processRecord(key, value, myIntOption, myStringOption);
19    }
20
21}
22
similar questions
queries leading to this page
java pass parameters to mapper