hadoop求共同好友案例

2021-10-25 05:52:35 字數 1709 閱讀 6272

4.1 需求分析

以下是qq的好友列表資料,冒號前是乙個使用者,冒號後是該使用者的所有好友(資料中的好友關係是單向的)

a:b,c,d,f,e,o

b:a,c,e,k

c:a,b,d,e,i

d:a,e,f,l

e:b,c,d,m,l

f:a,b,c,d,e,o,m

g:a,c,d,e,f

h:a,c,d,e,o

i:a,o

j:b,o

k:a,c,d

l:d,e,f

m:e,f,g

o:a,h,i,j

求出哪些人兩兩之間有共同好友,及他倆的共同好友都有誰?

public

class

extends }}

reducer類:

public

class

step1reducer

extends

reducer

//2:k2就是v3

//3:將k3和v3寫入上下文中

context.

write

(new

text

(buffer.

tostring()

), key);}

}

jobmain:

public

class

jobmain

extends

configured

implements

tool

public

static

void

main

(string[

] args)

throws exception

}

第二步:**實現

public

class

extends

}}}

reducer類

public

class

step2reducer

extends

reducer

//3:將k3和v3寫入上下文中

context.

write

(key,

newtext

(buffer.

tostring()

));}

}

jobmain

public

class

jobmain

extends

configured

implements

tool

public

static

void

main

(string[

] args)

throws exception

}

求共同好友案例 mapreduce實現

friends.txt a b,c,d,f,e,o b a,c,e,k c f,a,d,i d a,e,f,l需求 求每兩個人的共同好友 a和b,a和c a b,c,d,f,e,o b a,c,e,k 好友列表作為k b a c a d a a b c b e b 將matask端的value 本人...

mysql共同好友 Spark 實現共同好友

核心 如下 object sprk import org.apache.spark.sql.sparksession def main args array string unit logger.getlogger org setlevel level.off logger.getlogger ak...

使用hive求共同好友

乙個mapreduce的經典題目 求共同好友,目前網上還沒有人用hive實現,我來用hive算一下。一 資料準備 create table friends people string,friends string insert into table friends people,friends va...