hadoop map数量太少的问题

来源:互联网 发布:网站加速软件 编辑:程序博客网 时间:2024/04/30 07:06

某些时候map的数量太少,但是每个map的文件比较大,导致执行时间很长。为了充分利用hadoop的优势,我们把map的数据hash到更多的reduce节点去做处理。

使用随机数据都不是特别好,更好的方式是使用input line的hashCode。


public void map(LongWritable key, Text value,OutputCollector<Text, Text> output, Reporter reporter)throws IOException{   try   {String line = value.toString();rand=line.hashCode();x.set(rand.toString());y.set(line);output.collect(x,y);   } catch (Exception e)   {reporter.incrCounter("map", "exp", 1);   }}


原创粉丝点击