Iterate twice on values (MapReduce)

前端 未结 11 1089
轮回少年
轮回少年 2020-11-29 07:22

I receive an iterator as argument and I would like to iterate on values twice.

public void reduce(Pair key, Iterator          


        
11条回答
  •  庸人自扰
    2020-11-29 08:25

    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.

提交回复
热议问题