I receive an iterator as argument and I would like to iterate on values twice.
public void reduce(Pair key, Iterator
After searching and doing so many tries and errors, I found a solution.
Declare a new collection (say cache
) (linked list or Arraylist or any else)
Inside first iteration, assign the current iterator like below example:
cache.add(new Text(current.get()))
Iterate through cache:
for (Text count : counts) {
//counts is iterable object of Type Text
cache.add(new Text(count.getBytes()));
}
for(Text value:cache) {
// your logic..
}