I receive an iterator as argument and I would like to iterate on values twice.
public void reduce(Pair key, Iterator
Iterators are one-traversal-only. Some iterator types are cloneable, and you might be able to clone it before traversing, but this isn't the general case.
You should make your function take an Iterable instead, if you can achieve that at all.
Iterable