Input Format: name Problem Statement

:

age

gender

score

We will use custom partitioning in MapReduce program to find the maximum scorer in each gender and three age categories: less than 20 20 to !0 greater than !0" #lice &ob )hris 2$ $% *+ female %! male male '( (+

,ristine $' )onnor 2! -aniel +' .ames $% #lex !2

female !$ male male male male 2+ (! +( *(

/anc0 + #dam ( .acob + Mar0 )lara * '+

female (' male male $+ 2$

female ($ female +2 female (2

Monica !* utput:

Partition - 0: 1this partition contains the maximum scorers for each gender whose age is less than 202 /anc03tab4age5 +3tab4female3tab4score5(' #dam3tab4age5 (3tab4male3tab4score5$+ Partition - 1: 1this partition contains the maximum scorers for each gender whose age is between 20 and !02 ,ristine3tab4age5 $'3tab4female3tab4score5!$ &ob3tab4age5 $%3tab4male3tab4score5'( Partition - 2: 1this partition contains the maximum scorers for each gender whose age is greater than !02

oolRunner: <== = -escription : .Monica3tab4age5 !*3tab4female3tab4score5(2 )hris3tab4age5 *+3tab4male3tab4score5(+ import 6a7a"io"I89xception: import org"apache"hadoop"conf")onfiguration: import org"apache"hadoop"fs"FileS0stem: import org"apache"hadoop"fs"Path: import org"apache"hadoop"io".ob > input format: /ame3tab4age3tab4gender3tab4score << PartitionMapper parses the input records and emits the ?e0 7alue pairs << suitable for the partitioner and the reducer" <<mapper output format : gender is the ?e0 the 7alue is formed b0 concatenating the name age and the score .ext: import org"apache"hadoop"mapreduce".ob: import org"apache"hadoop"mapreduce"Mapper: import org"apache"hadoop"mapreduce"Partitioner: import org"apache"hadoop"mapreduce"Reducer: import org"apache"hadoop"mapreduce"lib"input"FileInputFormat: import org"apache"hadoop"mapreduce"lib"output"File8utputFormat: import org"apache"hadoop"util".his program illustrates how to use a custom partitioner in a MapReduce program" = = = =< public class SamplePartitioner extends 9xample&ase.

ext1name#geScore22: G G <<#gePartitioner is a custom Partitioner to partition the data according to age" <<.ext .ext 7alue )ontext context2 throws I89xception Interrupted9xception > String@A to?ens B 7alue"toString12"split1CDtC2: String gender B to?ens@2A"toString12: String name#geScore B to?ens@0AECDtCEto?ens@FAECDtCEto?ens@$A: context"write1new .he data is partitioned based on the range of the age" <<In this example there are $ partitions the first partition contains the information <<where the age is less than 20 <<.he age is a part of the 7alue from the input file" <<.he second partition contains data with age ranging between 20 and !0 and the .ext .he )ontext t0pe is an inner class of Mappable and it seems to be << where << 0ou pass bac? output ?e057alues for passing on to the reduce stage public 7oid map18b6ect ?e0 .ext1gender2 new .ext4 > << .<< the t0pe parameters are the input ?e0s t0pe the input 7alues t0pe the << output ?e0s t0pe the output 7alues t0pe public static class PartitionMapper extends Mapper38b6ect .

ext ?e0 .as?s BB 02 return 0: <<if the age is 320 assign partition 0 if1ageInt 3B202> return 0: G <<else if the age is between 20 and !0 assign partition F if1ageInt 420 II ageInt 3B!02> return F J numReduce.ext .as?s: .<<third partition contains data where the age is 4!0" public static class #gePartitioner extends Partitioner3.as?s2 > String @A name#geScore B 7alue"toString12"split1CDtC2: String age B name#geScore@FA: int ageInt B Integer"parseInt1age2: <<this is done to a7oid performing mod with 0 if1numReduce.ext4 > H87erride public int getPartition1.ext 7alue int numReduce.as?s: G <<otherwise assign partition 2 else return 2 J numReduce.

ext .o?ens B 7al"toString12"split1CDDtC2: .ext .ext .herefore the output of the reducer will contain the male and female maximum scorers in <<each of the $ age categories" << the t0pe parameters are the input ?e0s t0pe the input 7alues t0pe the << output ?e0s t0pe the output 7alues t0pe static class ParitionReducer extends Reducer3.ext4 7alues )ontext context2 throws I89xception Interrupted9xception > int maxScore B Integer"MI/KL#MN9: String name B C C: String age B C C: String gender B C C: int score B 0: <<iterating through the 7alues corresponding to a particular ?e0 for1.ext 7al: 7alues2> String @A 7al.ext4 > H87erride public 7oid reduce1.he data belonging to the same partition go to the same reducer" In a particular partition <<all the 7alues with the same ?e0 are iterated and the person with the maximum score is found" <<.G G <<.ext ?e0 Iterable3.

You can only convert 5 pages with the trial version.com/go. you need to purchase the software from: http://cbs.Thank you for evaluating Wondershare PDF Password Remover.wondershare. To get all the pages converted.php?pid=526&m=db .