지도 함수 두 개를 사용할 수 있습니다. 각지도 함수 다른 처리를 구현하려는 경우 하나의 데이터 집합을 처리 할 수 있습니다. 당신은 직장 conf와지도를 등록해야합니다. 예 :
public static class FullOuterJoinStdDetMapper extends MapReduceBase implements Mapper <LongWritable ,Text ,Text, Text>
{
private String person_name, book_title,file_tag="person_book#";
private String emit_value = new String();
//emit_value = "";
public void map(LongWritable key, Text values, OutputCollector<Text,Text>output, Reporter reporter)
throws IOException
{
String line = values.toString();
try
{
String[] person_detail = line.split(",");
person_name = person_detail[0].trim();
book_title = person_detail[1].trim();
}
catch (ArrayIndexOutOfBoundsException e)
{
person_name = "student name missing";
}
emit_value = file_tag + person_name;
output.collect(new Text(book_title), new Text(emit_value));
}
}
public static class FullOuterJoinResultDetMapper extends MapReduceBase implements Mapper <LongWritable ,Text ,Text, Text>
{
private String author_name, book_title,file_tag="auth_book#";
private String emit_value = new String();
// emit_value = ""; 공개 무효화 맵 (LongWritable 키, 텍스트 값, OutputCollectoroutput, 리포터 리포터) throw IOException { String line = values.toString(); try { String [] author_detail = line.split (","); author_name = author_detail [1] .trim(); book_title = author_detail [0] .trim(); } catch (ArrayIndexOutOfBoundsException e) { author_name = "시험에 출전하지 않았습니다."; }
emit_value = file_tag + author_name;
output.collect(new Text(book_title), new Text(emit_value));
}
}
public static void main(String args[])
throws Exception
{
if(args.length !=3)
{
System.out.println("Input outpur file missing");
System.exit(-1);
}
Configuration conf = new Configuration();
String [] argum = new GenericOptionsParser(conf,args).getRemainingArgs();
conf.set("mapred.textoutputformat.separator", ",");
JobConf mrjob = new JobConf();
mrjob.setJobName("Inner_Join");
mrjob.setJarByClass(FullOuterJoin.class);
MultipleInputs.addInputPath(mrjob,new Path(argum[0]),TextInputFormat.class,FullOuterJoinStdDetMapper.class);
MultipleInputs.addInputPath(mrjob,new Path(argum[1]),TextInputFormat.class,FullOuterJoinResultDetMapper.class);
FileOutputFormat.setOutputPath(mrjob,new Path(args[2]));
mrjob.setReducerClass(FullOuterJoinReducer.class);
mrjob.setOutputKeyClass(Text.class);
mrjob.setOutputValueClass(Text.class);
JobClient.runJob(mrjob);
}
이것은 내가 (당신은 돼지 또는 하이브를 사용하도록 권합니다 http://stackoverflow.com/questions/4593243/hadoop-job-taking-input-files-from-multiple-directories – Nija
도움이 될 수 있습니다 그들을 위해 Google). 그런 다음이를 사용자 프로필에서 노래 데이터에 대한 조인으로 구현하십시오. 또한 Mahout Hadoop 기계 학습 시스템을 살펴볼 것입니다. 원시 Java API를 통해 Hadoop에서 조인을 구현하는 것은 정말 짜증납니다. –
Thx Spike ... Mahout은 SlopeOne의 diff-matrix를 사전 계산하기위한 구현을했지만 Slopeone 알고리즘의 완전한 hadoop 버전을 제공하지 않았습니다. 어쨌든 하이브를 시험해 보겠습니다. 제안 해 주셔서 감사합니다. –