java - Hadoop MapReduce to conditionally print name pairs -


so trying figure out logic mapreduce program question, dont need code, need logic since still new mapreduce not acquainted possible ways tackle problem. tried looking similar programs, no luck.

question: given list of names (for simplicity consider first characters)

input:

a,b  d,f  p,e  a,b  a,c  b,a  e,p 

i need use mapreduce print pairs(in alphabetical order) have been mentioned in alphabetical order , in reverse order too.

so output be:

a,b  e,p 

note: e,p printed not p,e since has in alphabetical order.

can help?

in map-reduce programs main question is: key, , value. map-reduce programs work on key/value rules. define key , value, on next step can define other key , values, , on. example @ beginning key index(number) of raw, , value value in raw. in code in map function define new key, , value , went reduce function go through keys , make action values have same key.

classic example of map reduce word count program.

in example in map function can set key a pair in alphabetical order, , value pair itself in reduce function go through values of every key , looks reverse order, if have reverse order, write value result

after map function output be:

a,b a,b  a,b a,b a,b b,a a,c a,c d,f d,f e,p p,e e,p e,p 

after reduce:

a,b a,b p,e p,e 

Comments