我试图找出Map任务的输出在Reduce任务可以使用之前保存到磁盘的位置.
注意: - 使用的版本是带有新API的Hadoop 0.20.204
例如,在Map类中覆盖map方法时:
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
context.write(word, one);
}
// code that starts a new Job.
}
Run Code Online (Sandbox Code Playgroud)
我有兴趣找出context.write()最终写入数据的位置.到目前为止我遇到了:
FileOutputFormat.getWorkOutputPath(context);
Run Code Online (Sandbox Code Playgroud)
这给了我在hdfs上的以下位置:
hdfs://localhost:9000/tmp/outputs/1/_temporary/_attempt_201112221334_0001_m_000000_0
Run Code Online (Sandbox Code Playgroud)
当我尝试将它用作另一个作业的输入时,它会给我以下错误:
org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: hdfs://localhost:9000/tmp/outputs/1/_temporary/_attempt_201112221334_0001_m_000000_0
Run Code Online (Sandbox Code Playgroud)
注意:作业是在Mapper中启动的,因此从技术上讲,Mapper任务写入的临时文件夹的输出在新作业开始时存在.然后,它仍然说输入路径不存在.
有关临时输出写入的想法吗?或者也许在同时具有Map和Reduce阶段的作业中我可以找到Map任务输出的位置是什么?