Hadoop,怎么实现多个输入路径的输入?
答案:1 悬赏:0
解决时间 2021-01-17 22:48
- 提问者网友:雪舞兮
- 2021-01-17 18:04
Hadoop,怎么实现多个输入路径的输入?
最佳答案
- 二级知识专家网友:第四晚心情
- 2021-01-17 18:45
1.多路径输入
1)FileInputFormat.addInputPath 多次调用加载不同路径
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
String in0 = args[0];
String in1 = args[1];
String out = args[2];
FileInputFormat.addInputPath(job,new Path(in0));
FileInputFormat.addInputPath(job,new Path(in1));
FileOutputFormat.setOutputPath(job,new Path(out));2)FileInputFormat.addInputPaths一次调用加载 多路径字符串用逗号隔开
FileInputFormat.addInputPaths(job, "hdfs://RS5-112:9000/cs/path1,hdfs://RS5-112:9000/cs/path2");
2.多种输入
MultipleInputs可以加载不同路径的输入文件,并且每个路径可用不同的maper
MultipleInputs.addInputPath(job, new Path("hdfs://RS5-112:9000/cs/path1"), TextInputFormat.class,MultiTypeFileInput1Mapper.class);
MultipleInputs.addInputPath(job, new Path("hdfs://RS5-112:9000/cs/path3"), TextInputFormat.class,MultiTypeFileInput3Mapper.class);
追问谢谢您细致的回答^_^追答好好学习,天天向上~~~
1)FileInputFormat.addInputPath 多次调用加载不同路径
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
String in0 = args[0];
String in1 = args[1];
String out = args[2];
FileInputFormat.addInputPath(job,new Path(in0));
FileInputFormat.addInputPath(job,new Path(in1));
FileOutputFormat.setOutputPath(job,new Path(out));2)FileInputFormat.addInputPaths一次调用加载 多路径字符串用逗号隔开
FileInputFormat.addInputPaths(job, "hdfs://RS5-112:9000/cs/path1,hdfs://RS5-112:9000/cs/path2");
2.多种输入
MultipleInputs可以加载不同路径的输入文件,并且每个路径可用不同的maper
MultipleInputs.addInputPath(job, new Path("hdfs://RS5-112:9000/cs/path1"), TextInputFormat.class,MultiTypeFileInput1Mapper.class);
MultipleInputs.addInputPath(job, new Path("hdfs://RS5-112:9000/cs/path3"), TextInputFormat.class,MultiTypeFileInput3Mapper.class);
追问谢谢您细致的回答^_^追答好好学习,天天向上~~~
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息