在java中我会使用:
MultipleInputs.addInputPath(conf, path, inputFormatClass, mapperClass)
为每个添加具有不同映射器的多个输入。
现在我正在使用python在hadoop中编写一个流式作业,可以完成类似的工作吗?
您可以使用多个 -input 选项来指定多个输入路径:
hadoop jar hadoop-streaming.jar -input foo.txt -input bar.txt ...
我想这可以帮助你:https ://github.com/hyonaldo/hadoop-multiple-streaming 。
在这里,您还可以看到“这些不同输入路径的不同映射器”:
hadoop jar hadoop-multiple-streaming.jar \
-input myInputDirs \
-multiple "outputDir1|mypackage.Mapper1|mypackage.Reducer1" \
-multiple "outputDir2|mapper2.sh|reducer2.sh" \
-multiple "outputDir3|mapper3.py|reducer3.py" \
-multiple "outputDir4|/bin/cat|/bin/wc" \
-libjars "libDir/mypackage.jar" \
-file "libDir/mapper2.sh" \
-file "libDir/mapper3.py" \
-file "libDir/reducer2.sh" \
-file "libDir/reducer3.py"