标签:
Just like this!!!!!!!!!!!!!!!!
===============================================================
 public static class Reduce extends MapReduceBase implements
  Reducer<IntWritable, Text, NullWritable, Text> {
 
    @Override
    public void reduce(IntWritable dummy, Iterator<Text> values,
        OutputCollector<NullWritable, Text> output, Reporter reporter)
            throws IOException { 
    	
    	List<Text> cache = new ArrayList<Text>();
    	// first loop and caching   
    	while (values.hasNext()) {
    		 
    	   cache.add(new Text(values.next()));
    		  
    	}
    	 
    	// second loop 
    	for(Text p:cache) {
    	 
           output.collect(NullWritable.get(), p);
       	 
    	} 
      
    }
  }  Java 中如何对 Iterator<Text> values 实现两次遍历
标签:
原文地址:http://blog.csdn.net/yaoxiaochuang/article/details/50910204