Iterators in a reducer are not as simple as you might think.
The problem is that the total number of elements that you repeat may not fit into memory. This means that the iterator can read from disk. If you have two independent copies of the iterator, then you can have one of them far ahead of the other, which means that the data between the two points of the iterator cannot be deleted.
For ease of implementation, Hadoop does not support having more than one iterator for reduction values.
The practical effect of this is that you cannot go through the same iterator twice. This is not good, but it is. If you absolutely know that the number of items will fit into the memory, you can copy all the elements to the list, as suggested by MrGomez. If you do not know this, you may need to use secondary storage.
The best approach is to reverse engineer your program so you don't need unlimited storage in the gearbox. This may be a bit confusing, but there are standard approaches to the problem.
For your specific problem, you have a quadratic increase in output size compared to the largest reduction input set. This is usually a very bad idea. In most cases, you do not need ALL pairs, only the most important pairs. If you can somehow trim the set of pairs, then you are all set up and you can remove the restriction of all pairs.
For example, if you try to find 100 pairs with the largest amount for each set of abbreviations, you can save the priority order with the 100 largest data currently nested and the priority queue with the 100 largest sums. For each new input, you can generate the sum with the largest 100 numbers, who have seen so far, and try to insert these amounts in the second place. Finally, you must insert the new input first and trim both queues to 100 elements, deleting the smallest values ββ(if necessary). In the method of closing the reduction method, you must reset the priority queue. This approach ensures that you only need minimal (n ^ 2, 200) storage items that avoid the n ^ 2 problem and avoid double-passing through the entrance, saving the 100 largest items, not all items seen.