Hadoop 控制多路输出格式文件子路径
我需要根据reducer键控制由multipleOutFormat管理的不同文件的子路径 我基本上想根据提供给reducer的键设置文件的子路径 我可以通过对multipleOutFormat的generateFileNameForKeyValue方法进行过度编译来更改文件名,但是如何更改这些文件的子路径呢 我的意思是,只要覆盖generateFileNameForKeyValue,我就可以Hadoop 控制多路输出格式文件子路径,hadoop,Hadoop,我需要根据reducer键控制由multipleOutFormat管理的不同文件的子路径 我基本上想根据提供给reducer的键设置文件的子路径 我可以通过对multipleOutFormat的generateFileNameForKeyValue方法进行过度编译来更改文件名,但是如何更改这些文件的子路径呢 我的意思是,只要覆盖generateFileNameForKeyValue,我就可以 mySetJobConfigOutputPath/fileNameBasedKey1.dat
mySetJobConfigOutputPath/fileNameBasedKey1.dat
/fileNameBasedKey2.dat
/fileNameBasedKey3.dat
...
但我想让它成为像下面这样组织文件
mySetJobConfigOutputPath/path0ConfiguredInsideReducerBasedOnKey/fileNameBasedKey1.dat
/path1ConfiguredInsideReducerBasedOnKey/fileNameBasedKey2.dat
/fileNameBasedKey3.dat
/path2ConfiguredInsideReducerBasedOnKey/fileNameBasedKey8.dat
如图所示,子路径和文件名都是由reducer中的键计算出来的
我知道如何配置文件名,但想知道是否可以在mySetJobConfigOutputPath文件夹下配置每个文件的子路径?我发现我也可以覆盖getInputFileBasedOutputFileName方法,并将其中的子路径提供给它
@Override
protected String getInputFileBasedOutputFileName(JobConf conf, String Name)
{
//your logic goes here. Simply addd the sub path to the name and return
}
您仍应实现generateFileNameForKeyValue以将潜在客户文件名转换为密钥
更新:基本上这就解释了一切试试这个