hadoop - 当某些键集的值过多时如何平衡 reducer ?

标签 hadoop mapreduce reduce

由于数据不是很均衡,按key(must)聚类时,有的key集数据多,有的少。在这种情况下我该如何平衡? 我已经研究了 InputSampler,它会起作用吗?

最佳答案

您可以实现自定义哈希分区器,这样您就可以将更高频率的键发送到一个缩减器,而将所有其他键以更低的频率发送到其他缩减器。

public static class AgePartitioner extends Partitioner<Text, Text> {

        @Override
        public int getPartition(Text key, Text value, int numReduceTasks) {




            //we have more keys in this range so we want to sent them to one reducer
            if(key >20 && key <=30){

                return 1 ;
            }
           else
                return 0;

        }
    }

关于hadoop - 当某些键集的值过多时如何平衡 reducer ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29689651/

相关文章:

python - Python中的过滤操作

javascript - 减少多维数组求和js的错误

amazon-web-services - 如何更改在 AWS 数据管道中运行的 Hive 事件的内存设置?

hadoop - Windows 中的 Nutch 1.14 给出异常 java.lang.UnsatisfiedLinkError : org. apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z

hadoop - key不在第一行: Hadoop Mapreduce时如何使用mapreduce

Javascript 递归标准化 JSON 数据

java - 编译错误java hadoop程序

hadoop - Nutch 2.0 和 Hadoop。如何防止缓存 conf/regex-urlfilter.txt

java - MapReduce java.lang.ArrayIndexOutOfBoundsException : 0

amazon-web-services - 使用亚马逊弹性mapreduce服务时如何在hadoop中包含第三方库