gpt4 book ai didi

hadoop - 如何在Hadoop程序中移动文件?

转载 作者:行者123 更新时间:2023-12-02 19:36:14 24 4
gpt4 key购买 nike

我希望能够从相同的reducer输出写入多个目录。我正在使用MultipleOutput写入多个文件。现在,我想将这些文件移动到其他目录。如何在Java的Hadoop MapReduce程序中做到这一点?

最佳答案

很简单使用FileSystem.rename。例如。,

    Configuration conf = ...;
Job job = ...;
Path output = new Path("your_map_reduce_output_dir");
// ...
if(job.waitForCompletion(true)) {
FileSystem fs = FileSystem.get(conf);
Path dest = new Path("your_dest_dir");
return fs.rename(output, dest);
}
else {
return false;
}

关于hadoop - 如何在Hadoop程序中移动文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22925776/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com