mapreduce实现QQ好友推荐
来源:互联网 发布:电话线传网络 编辑:程序博客网 时间:2024/05/18 02:18
文件
hadoop hello
hdfs worldtom cat
cat dog
hello world
hello hdfs
输出
tom dog
dog tom
hello world
world hello
hdfs world
hdfs hadoop
world hdfs
world hadoop
hadoop hdfs
hadoop world
hello hdfs
hdfs hello
public class QQMapper extends Mapper<LongWritable, Text, Text, Text> { @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String line = value.toString(); String[] ss = StringUtils.split(line, "\\s+"); context.write(new Text(ss[0]), new Text(ss[1])); context.write(new Text(ss[1]), new Text(ss[0])); } }
public class QQReducer extends Reducer<Text, Text, Text, Text> { @Override protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException { Set<String> set = new HashSet<String>(); for (Text text : values) { set.add(text.toString()); } if (set.size() > 1) { for (Iterator j = set.iterator(); j.hasNext();) { String name = j.next(); for (Iterator i = set.iterator(); i.hasNext();) { String other = i.next(); if (!name.equals(other)) { context.write(new Text(name), new Text(other)); } } } } } }
阅读全文
0 0
- MapReduce实现QQ好友推荐
- MapReduce实现QQ好友推荐
- mapreduce实现QQ好友推荐
- MapReduce实现QQ好友推荐
- 用hadoop2.7.1 mapreduce实现QQ好友推荐功能
- 基于mapreduce实现好友推荐功能
- 一些算法的MapReduce实现——好友推荐
- MapReduce学习之好友推荐
- Hadoop/MapReduce 好友推荐解决方案
- 实现QQ 好友列表
- MapReduce实现寻找共同好友
- android 实现QQ好友列表
- mapreduce实现推荐系统
- MapReduce实现推荐系统
- mapreduce实现推荐系统
- ClipboardManager实现支付宝推荐微信QQ好友复制文字启动支付宝弹出提示框实现
- [hadoop]MapReduce实例之好友推荐(六)
- QQ好友分组添加好友(UITableView实现)
- AX 文件操作示例
- 华为荣耀系列手机无法查看logcat
- Android学习日志——第13天(补)
- 2.4 分类算法:KNN
- Error:Could not load file“*.AXF” Debugger aborted!
- mapreduce实现QQ好友推荐
- php中的Session、Cookie
- Linux-文件权限
- Hex格式和Mot格式简介
- 【软考】权法-反不正当竞争法
- 产品框架初步设计后,如何为每个部件定义一个清晰的职责范畴?
- C# 连接 Oracle 的几种方式
- 用C#编程合并多个WORD文档
- maven编译的时候跳过test