我有2个不同格式的文件。一个是SequenceFileInputFormat
,另一个是TextInputFormat
。我知道对于Hadoop Streaming,有可能指定2个输入文件,如:
hadoop jar hadoop-streaming-2.8.0.jar \
-input '/user/foo/dir1' -input '/user/foo/dir2' \
(rest of the command)
但是如何为这些文件指定不同的-inputformat
?
我发现使用MultipleInputs
可以为Java做:
MultipleInputs.addInputPath(job, new Path(args[0]), <Input_Format_Class_1>);
MultipleInputs.addInputPath(job, new Path(args[1]), <Input_Format_Class_2>);
我可以用Hadoop Streaming做这样的事吗?
Hadoop Streaming Options包含hadoop流的各种选项,在你的情况下可能会使用的那个
-inputformat JavaClassName
默认值为TextInputFormat
我仅使用TextInputFormat对此进行了测试,但我应该重新调整它
hadoop jar hadoop-streaming-2.8.0.jar \
-input '/user/foo/dir1' -inputformat TextInputFormat \
-input '/user/foo/dir2' -inputformat SequenceFileInputFormat \
(rest of the command)
以下是经过测试并且有效的方法:
hadoop jar /usr/lib/hadoop-mapreduce/hadoop-streaming-2.6.0*.jar \
-file mapperB.py -mapper mapperB.py -file reducerB.py -reducer reducerB.py \
-input /tempfiles/big.txt -inputformat TextInputFormat \
-input /tempfiles/t.txt -inputformat TextInputFormat \
-output /tempfiles/output-X
注意:file
已弃用,