我正在尝试通过Scala组合HDF中存在的3个文件。所有3个文件都存在于HDFS位置srcPath
中,如下所述。
创建一个如下的函数:
def mergeFiles(conf: Configuration, fs: FileSystem, srcPath: Path, dstPath: String, finalFileName: String): Unit {
val localfs = FileSystem.getLocal(conf)
val status = fs.listStatus(srcPath)
status.foreach(x =>
FileUtil.copyMerge(fs, x.getPath, localfs, new Path(dstPath.toString), false, conf, null)
}
我尝试执行此操作,没有结果,没有错误,也没有创建文件。我验证了我正在正确地传递所有论点。
有线索?
copyMerge
的第二个参数是目录,而不是单个文件。这应该有效:
FileUtil.copyMerge(fs, srcPath, localfs, new Path(dstPath.toString), false, conf, null)
通常读取源代码是调试此类问题的最佳方法。
fileutil#copymerge方法已被删除。有关主要更改的详细信息:
https://issues.apache.org/jira/browse/hadoop-12967
https://issues.apache.org/jira/browse/hadoop-11392
您可以使用getmerge
用法:hadoop fs -getmerge [-nl]