zoukankan      html  css  js  c++  java
  • java.io.IOException: Illegal partition for 67 (-1)

    今天写MapReduce的分区进行排序的功能,自己写了一个Partitioner,然后用的时候就错了

    public static class MyPartition extends Partitioner<IntWritable, IntWritable> {
        @Override
        public int getPartition(IntWritable key, IntWritable value, int numTaskReduce) {
    
            int maxNumber = 550;
            int end = maxNumber/numTaskReduce + 1;
            int keyNum = key.get();
            for(int i=0; i<numTaskReduce; i++) {
                if(keyNum >= end*i && keyNum <= end*(i+1)) {
                    return i;
                }
            }
            return -1;
        }
    }

    后来发现应该是返回了-1,导致了出错的,分区默认是从0开始的,返回-1肯定就报错了。

  • 相关阅读:
    hdoj 1002 A + B Problem II
    hdoj 1234 开门人和关门人
    hdoj 2203 亲和串
    nyoj 73 比大小
    81B
    信息传递
    bzoj1787
    最少交换次数
    100803C
    火柴排队
  • 原文地址:https://www.cnblogs.com/tuhooo/p/7843583.html
Copyright © 2011-2022 走看看