mapreduce - Resetting Iterable Object -


i writing mr job in reducer side, need check size of iterable before doing anything. did asked same question long back(how find size of iterable object?) solutions given not working.since iterable doesnt have size() method, please suggesst me how it. tried following options.

  1. tried iterator object iterable, got following typecast error. same error resettableiterator. java.lang.classcastexception: org.apache.hadoop.mapreduce.reducecontext$valueiterator cannot cast java.util.listiterator

  2. if iterate end of iterable object size, how can go start of index.

  3. if(values instanceof collection){ return ((collection)values).size(); } doesnt hit values of different type.

please me sample code. issue has taken lot of time. lot.!!

  1. iterator iterator = use values.iterator(); iterator.
  2. store values in list or other data structure , iterate on it.

Comments