java.lang.ArrayIndexOutOfBoundsException: -1 报错行setSize(position[count-1]);

java.lang.ArrayIndexOutOfBoundsException: -1

at cn.m15.ipj.writable.MultiBytesWritable.readFields(MultiBytesWritable.java:187)
 
 
点击进入这个错误提示时:为MultiBytesWritable类的readFields方法
public void readFields(DataInput in) throws IOException 
{
	int count = in.readInt();
	position = new int[count];
	for(int i = 0; i < count; i++) {
		position[i] = in.readInt();
	}
	setSize(0); 	
    setSize(position[count-1]);//红色
    in.readFully(bytes, 0, size);
}
 
 注:红色行为报错行
 
原因:
        map方法中要写如reduce的key值不合理
解决方法:
        调整map方法中要写入reduce的key值

你可能感兴趣的:(mapreduce,hadoop)