mapreduce多路径输入单文件输出

做Mapreducer练习时碰到一个问题:清洗5天的日志

分析
由于五天日志是五个不同的文件,setInputPaths方法,传入两个不同的路径,最后输出到hadoop文件系统会被后一个覆盖,所以应该传入路径的数组就行了
代码如下(两个文件为例)
Path[] paths = {new Path("hdfs://liquanhong1:9000//localhost_access_log.2017-06-23.txt"),new Path("hdfs://liquanhong1:9000/22")};
FileInputFormat.setInputPaths(job,paths);
FileOutputFormat.setOutputPath(job,new Path("hdfs://liquanhong1:9000/test630"));
System.out.println("輸出:"+job.waitForCompletion(true));

这个很简单,以后注意就行了




发布了30 篇原创文章 · 获赞 76 · 访问量 12万+

猜你喜欢

转载自blog.csdn.net/a1275302036/article/details/73961031
今日推荐