- 12
- 0
- 约1.23万字
- 约 52页
- 2019-11-03 发布于天津
- 举报
//we need to customize a new Writable format to represent a //term’s Info public class SingleRecordWritable implements WritableComparableSingleRecordWritable { private LongWritable DID=new LongWritable(); //DID private FloatWritable rank=new FloatWritable(); //Rank private Text positions=new Text(); //Positions ….. } Build Inverted Index --Pseudo Code(1) public class Mapper extends MapperLongWritable, Text, Text, SingleRecordWritable{ public HashMapTerm,Rank_Positions TokenMap; //TMP Info public void map(LongWritable offset,Text val,Context context) { String[] str=val.toString().split(\007, 5); //Split post to get title and content HandleToken(str[3],true); HandleToken(str[4],false); //store line’s terms in TMP Info this.EmitMapValue(key,context); //After scaned the whole text,emit key and value } //Handle input line:segement into words,handle the words one by one. public HandleToken (Iine,IsTitle){ while(line.hasnext()){ if(TokenMap.contians(line.GetTerm()) TokenMap.Update(line.GetTerm());//if TMP don’t contains the word put in TMP else TokenMap.Put(line.GetTerm()); //Update the term’s info in TMP.} } public void EmitMapValue(LongWritable key,Context context) { for(Map.EntryString,Rank_Positions entry:TokenMap.entrySet()) context.write(word, singleRecord); //emit the key/value pair one by one } Build Inverted Index --Pseudo Code(2) public class LineIndexerReducer extends ReducerText,SingleRecordWritable,Text,Text { //reduce’s input key is a term,input value is a List of Infos that //contains the same term,each info represent a Doc. public void reduce(Text key, IterableSingleRecordWritable values,Context context){ StringBuilder Info; for(SingleRecordWritable val:values) Info.append(ResetFinalRank(val,values.len)+;); out.set(info.toString()); context.write(key,out); } //The Num of doucment that a t
您可能关注的文档
最近下载
- 塔机维保合同7篇.docx VIP
- DB51T 900-2025川产道地药材生产技术规程 川贝母(暗紫贝母、川贝母、瓦布贝母).pdf VIP
- 三年(2023-2025)中考道德与法治真题分类汇编:专题12 维护国家利益(解析版).docx VIP
- 高中生涯规划教育与学科教学融合的创新路径探讨教学研究课题报告.docx
- NFS_3030_中文编程手册_完全版.pdf VIP
- 儿科肺炎患儿呼吸护理技巧.pptx VIP
- 奇妙三数字趋势学习心得.pptx VIP
- 鸡胴体等级及要求、鸡分割肉等级及要求.pdf VIP
- 建设工程造价司法鉴定实务指南.docx VIP
- 2025年XX村集体三资四议两公开会议记录.doc VIP
原创力文档

文档评论(0)