📜  java 将参数传递给映射器 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:19.059000             🧑  作者: Mango

代码示例1
public static class MyMapper extends MapReduceBase implements Mapper<...> {

    Integer myIntegerOption;
    String myStringOption;

    @Override
    public void configure(JobConf job) {
        super.configure(job);
        myIntegerOption = job.getInt("myIntOption", -1); 
        // nb: last arg is the default value if option is not set
        myStringOption = job.get("myStringOption", "notSet");
    }

    @Override
    public void map(... key, ... value, 
                    OutputCollector<..> output, Reporter reporter) throws IOException {
        // here you can use the options in your processing
        processRecord(key, value, myIntOption, myStringOption);
    }

}