支持多路输出(SuffixMultipleTextOutputFormat)
如下示例:
hadoop streaming \
-input /home/mr/data/test_tab/ \
-output /home/mr/output/tab_test/out19 \
-outputformatorg.apache.hadoop.mapred.lib.SuffixMultipleTextOutputFormat\ # 指定outputformat为org.apache.hadoop.mapred.lib.SuffixMultipleTextOutputFormat
-jobconf suffix.multiple.outputformat.filesuffix=a,c,f,abc,cde \ # 指定输出文件名的前缀,所有需要输出的文件名必须通过该参数配置,否则job会失败
-jobconf suffix.multiple.outputformat.separator="#"\ # 设置value与文件名的分割符,默认为“#”,如果value本身含有“#”,则可以通过该参数设置其他的分隔符
-mapper "cat" \
-reducer "sh reduce.sh" \
-file reduce.sh
注:标记为红色的参数必须设置!
1.mapreduce多路径输入
1.1fileinputformat.addinputpath(s)
fileinputformat.addinputpath()是我们最常用的设置mapreduce输入路径的方法了。其实,fileinputformat有两个这样的方法:
[html] view plain copy
static void addinputpath(job job, path path)
static void addinputpaths(job job, string commaseperatedpaths)
addinputpath()只能指定一个路径,如果要想添加多个路径需要多次调用该方法:
[java] view plain copy
fileinputformat.addinputpath(job, new path(args[0]));
fileinputformat.addinputpath(job, new path(args[1]));
fileinputformat.addinputpath(job, new path(args[2]));
addinputpaths()可以指定多条路径,而这多条路径是用“,”分隔的一个字符串:
[java] view plain copy
string paths = strings[0] + "," + strings[1];
fileinputformat.addinputpaths(job, paths);
Hadoop|
Apache Pig|
Apache Kafka|
Apache Storm|
Impala|
Zookeeper|
SAS|
TensorFlow|
人工智能基础|
Apache Kylin|
Openstack|
Flink|
MapReduce|
大数据|
云计算|
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....