2016-08-24 5 views
0

reducer의 출력을 list에 추가하고 모든 값을 읽은 후 액세스하여 목록을 인쇄하려고합니다. 예상대로 작동하지 않는 경우,Reducer의 출력을 Hadoop의 목록에 추가하십시오.

public class Reducer extends Reducer<Text, BooleanWritable, Text, BooleanWritable> { 
    public static final Logger LOG = LoggerFactory.getLogger(Reducer.class); 
    public List<String> keys= new ArrayList<>(1000); 

    public void reduce(Text key, Iterable<BooleanWritable> values, Context context) throws IOException, InterruptedException { 
    for (BooleanWritable value : values) { 
     keys.add(key.toString()); 
     context.write(key, value); 
    } 
    print(keys); 
    } 

    private void print(String keys) { 
    for (String key : keys) { 
     LOG.info(key); 
    } 
} 

하지만 - 다음은

내가 뭐하는 거지입니다. 감속기의 모든 값이 추가 된 후 목록을 한 번만 인쇄하려고합니다. list

답변

2

감속기 작업 당 한 번 호출해야하는 것을 사용해야합니다. protected void cleanup(org.apache.hadoop.mapreduce.Reducer.Context context) throws IOException,InterruptedException

documentation을 참조하십시오.

관련 문제