我正在尝试使用新的api进行map reduce,并将一个常规的expression作为a-d命令行参数传入,但是没有得到它。结果是pattern.compile(pattern)得到一个 NullPointerException
我的Map器代码是;
public class MdacMapper extends Mapper<Text, Text, Text, Text> {
private Pattern compiledPattern;
public void setup(Context context) {
Configuration config = context.getConfiguration();
String pattern = config.get("mapper.pattern");
compiledPattern = Pattern.compile(pattern);
}
// mapper
}
我的控制器代码是;
public class JobController {
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Job job = new Job(conf);
job.setJarByClass(JobController.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setMapperClass(MdacMapper.class);
job.setReducerClass(MdacReducer.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(Text.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.waitForCompletion(true);
job.submit();
}
}
最后,我要做的命令行调用是;
hadoop jar mapreducer.jar /input/aclogdrop /output/acjava \
-Dmapper.pattern=".*\|(\d{8}):\d*\.\d*\|(\d+)\|AC_ADO_QRY\(\d*?\)\|\d?\s?\[\s?(.*?)\]"
有什么建议为什么我不能选择配置参数mapper.pattern吗?
3条答案
按热度按时间0aydgbwb1#
此外,使用工具接口时,必须首先在命令中指定泛型选项(例如-d property=value),然后指定应用程序参数。
正确的命令如下所示:
svmlkihl2#
也许你应该用
GenericOptionsParser
.下面是api GenericOptions解析器
dy1byipe3#
您想使用工具界面-例如: