MR找共同朋友,数据格式如下:
A B C D E FB A C D EC A B ED A B EE A B C DF A
第一字母表示本人,其他是他的朋友,找出有共同朋友的人,和共同朋友是谁
1 import java.io.IOException; 2 import java.util.Set; 3 import java.util.StringTokenizer; 4 import java.util.TreeSet; 5 6 import org.apache.hadoop.conf.Configuration; 7 import org.apache.hadoop.fs.Path; 8 import org.apache.hadoop.io.Text; 9 import org.apache.hadoop.mapreduce.Job;10 import org.apache.hadoop.mapreduce.Mapper;11 import org.apache.hadoop.mapreduce.Reducer;12 import org.apache.hadoop.mapreduce.Mapper.Context;13 import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;14 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;15 import org.apache.hadoop.util.GenericOptionsParser;16 17 public class FindFriend {18 19 public static class ChangeMapper extends Mapper
运行结果:
AB E:C:DAC E:BAD B:EAE C:B:DBC A:EBD A:EBE C:D:ABF ACD E:A:BCE A:BCF ADE B:ADF AEF A
转自:http://www.aboutyun.com/thread-11107-1-1.html