2012-12-30 2 views
1

코드를 실행할 때 감속기의 작업에서 ArrayIndexOutOfBoundsException 오류가 발생합니다.ArrayIndexOutOfBoundsException 오류

... 
12/12/30 09:06:01 INFO mapred.JobClient: map 100% reduce 33% 
12/12/30 09:06:03 INFO mapred.JobClient: Task Id : attempt_201212271308_0005_r_000000_0, Status : FAILED 
java.lang.ArrayIndexOutOfBoundsException: 1 
     at org.apache.hadoop.io.WritableComparator.readInt(WritableComparator.java:153) 
     at org.apache.hadoop.io.BooleanWritable$Comparator.compare(BooleanWritable.java:103) 
     at org.apache.hadoop.mapreduce.ReduceContext.nextKeyValue(ReduceContext.java:120) 
     at org.apache.hadoop.mapreduce.ReduceContext.nextKey(ReduceContext.java:92) 
     at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:175) 
     at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:566) 
     at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:408) 
     at org.apache.hadoop.mapred.Child.main(Child.java:170) 

가 어떻게이 문제를 해결할 수 다음과 같이

public void map(ImageHeader key, FloatImage value, Context context) throws IOException, InterruptedException{ 
    if (value != null) { 
     mapcounter++; 
     FloatImage gray=new FloatImage(value.getWidth(),value.getHeight(),value.getBands()); 

     int imageWidth = value.getWidth(); 
     int imageHeight = value.getHeight(); 

     for (int x = 0; x < imageWidth-1; x++) { 

      for (int y = 0; y < imageHeight-1; y++) { 
       float red =value.getPixel(x, y, 0); 
       float green =value.getPixel(x, y, 1); 
       float blue =value.getPixel(x, y, 2); 
       //average of RGB 
       float avg = (red + blue + green)/3; 

       //set R, G & B with avg color 
       gray.setPixel(x, y, 0, avg); 
       gray.setPixel(x, y, 1, avg); 
       gray.setPixel(x, y, 2, avg); 
      } 
     } 

     ImageEncoder encoder = JPEGImageUtil.getInstance(); 

     FSDataOutputStream os = fileSystem.create(outpath); 
     encoder.encodeImage(gray, key, os); 
     os.flush(); 
     os.close(); 

     context.write(new BooleanWritable(true), new LongWritable(1)); 
    } 
    else 
     context.write(new BooleanWritable(false), new LongWritable(0)); 
} 
public static class MyReducer extends Reducer<BooleanWritable, LongWritable, BooleanWritable, LongWritable> { 

    public void reduce(BooleanWritable key, Iterable<LongWritable> values, Context context) 
     throws IOException, InterruptedException 
     { 
      System.out.println("REDUCING"); 
      for (LongWritable temp_hash : values) 
      { 
        context.write(new BooleanWritable(true), new LongWritable(1)); 
      }//for 
     } 
} 

오류는 다음과 같이

내 코드는?

두 번째 질문 : 내 프로그램에서 단계 감소를 무시하고 단계 감소를 실행하지 않으려면 어떻게해야합니까?

답변

0

아파치 후프의 버그입니다. 그들은 다음과 같이 수정했다고 주장했다.

MAPREDUCE-365의 일부로 수정되었습니다.

버그에 대한 자세한 내용은 here을 참조 할 수 있습니까?

+0

감사합니다. 나는 그것을 검사했다. 그것은 효과가 있었다. 고마워요 :) – Abolfazl

관련 문제