我有两份工作。 第一个作业map / reduce仅获取两个值: context.write(一,二)。 但是在第二个job map / reduce中我需要一个文件和两个值。
我尝试将结果放在上下文中的第一份工作
在减速机中
@Override
protected void cleanup(Context context)
throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
conf.setFloat("one",valorOne);
conf.setFloat("two",valorTwo);
}
在第二份工作的映射器中获取:
@Override
protected void setup(Context context) throws IOException,
InterruptedException {
Configuration conf = context.getConfiguration();
one=conf.getFloat("one",0f);
two=conf.getFloat("two",0f);
}
但值是空的。
在跑步中
public int run(String[] args) throws Exception {
Job job = Job.getInstance(getConf(), "1job");
job.setJarByClass(job.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
job.setMapOutputKeyClass(IntWritable.class);
job.setMapOutputValueClass(ValoresWritable.class);
job.setOutputKeyClass(IntWritable.class);
job.setOutputValueClass(ValoresWritable.class);
job.setMapperClass(Job1Map.class);
job.setCombinerClass(Job1Reducer.class);
job.setReducerClass(Job1Reducer.class);
FileInputFormat.addInputPath(job, new Path(input));
FileOutputFormat.setOutputPath(job, new Path(output));
job.waitForCompletion(true);
Job job2 = Job.getInstance(getConf(), "job2");
job2.setJarByClass(job.class);
job2.setInputFormatClass(TextInputFormat.class);
job2.setOutputFormatClass(TextOutputFormat.class);
job2.setMapOutputKeyClass(IntWritable.class);
job2.setMapOutputValueClass(IntWritable.class);
job2.setOutputKeyClass(IntWritable.class);
job2.setOutputValueClass(IntWritable.class);
job2.setMapperClass(Job2Map.class);
job2.setReducerClass(Job2Reduce.class);
我做错了什么? 感谢