在 hadoop reducer 中检索全局参数 returns null
retrieving global parameter in hadoop reducer returns null
我像这样为作业设置了一个全局变量:
Configuration conf = new Configuration();
Job job = new Job(conf, "new_job");
conf.set("attribute", "value");
我是这样在reducer中访问的,查看了值:
Configuration conf = context.getConfiguration();
attribute = conf.get("attribute");
System.out.println("attribute:"+attribute);
但它的值打印为 null,也
NullPointerException
在尝试使用检索到的变量时遇到
attribute
稍后在代码中。
请帮我找出问题所在。
将 conf 传递到作业中最终会从配置对象复制属性。您应该在构建 Job
之前设置属性
Configuration conf = new Configuration();
conf.set("attribute", "value");
Job job = new Job(conf, "new_job");
我像这样为作业设置了一个全局变量:
Configuration conf = new Configuration();
Job job = new Job(conf, "new_job");
conf.set("attribute", "value");
我是这样在reducer中访问的,查看了值:
Configuration conf = context.getConfiguration();
attribute = conf.get("attribute");
System.out.println("attribute:"+attribute);
但它的值打印为 null,也
NullPointerException
在尝试使用检索到的变量时遇到
attribute
稍后在代码中。
请帮我找出问题所在。
将 conf 传递到作业中最终会从配置对象复制属性。您应该在构建 Job
之前设置属性Configuration conf = new Configuration();
conf.set("attribute", "value");
Job job = new Job(conf, "new_job");