我有一个非常大的输入文本文件,格式如下:
ID \t time \t product \t Description \t Status
“状态”列仅限于包含小写字母a、s、i或大写字母a、s、i或两者的混合(状态列中的示例元素:a、si、i、asi、asi、asi、asi…)
我想要实现的是使用MapReduce根据状态过滤出这个输出文件。我想丢弃原始文件中至少有一个大写字母处于状态的所有行。换句话说,我只关心status中所有小写字母的行。在
我是MapReduce编程新手,需要一些帮助。以下是我目前为止的想法
我的映射器.py是:
^{pr2}$我的减速器.py是:
import sys
#I'm assuming that I have read in status and portions.
#In my understanding, the number of output files depend on the number of reducers. But what I want is to discard all rows that has at least 1 upper case letter in status bar.
#The file output should be a single file with rows that have all lower case letters in status bar.
我认为检查status是否至少有一个大写字母并不困难,但我在如何丢弃不感兴趣的行并将所有输出文件合并为一个与原始文本文件格式相同的文件时遇到了难题。在
如果能帮我找到正确的道路,我将不胜感激。提前谢谢你!在
你完全可以不用减速器
在你的地图上是这样的:
有关读/写HDFS的详细信息,请参阅Hadoop Streaming的文档。在
像这样的东西,例如:
^{pr2}$注意如何指定
-jobconf mapred.reduce.tasks=0
来告诉Hadoop您不需要reduce步骤。在相关问题 更多 >
编程相关推荐