我有两份工作。第一个作业map/reduce只获取两个值:context.write(one,two)。但是在第二个jobs map/reduce中,我需要一个文件和两个值。
我试着把第一份工作的结果放在上下文中
在减速器中
@Override
protected void cleanup(Context context)
throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
conf.setFloat("one",valorOne);
conf.setFloat("two",valorTwo);
}
在第二个任务的Map绘制者那里得到:
@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);
我做错了什么?谢谢
暂无答案!
目前还没有任何答案,快来回答吧!