Difference between revisions of "Mutual Friends MapReduce Application"

From CSE231 Wiki
Jump to: navigation, search
(Code To Implement)
(Code To Investigate)
 
(6 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
=Background=
 
=Background=
 
[http://stevekrenzel.com/finding-friends-with-mapreduce Steve Krenzel Finding Friends]
 
[http://stevekrenzel.com/finding-friends-with-mapreduce Steve Krenzel Finding Friends]
 +
 +
=Code To Investigate=
 +
==Account==
 +
[https://www.cse.wustl.edu/~cosgroved/courses/cse231/current/apidocs/mapreduce/apps/friends/core/Account.html class Account]
 +
: [https://www.cse.wustl.edu/~cosgroved/courses/cse231/s20/apidocs/mapreduce/apps/friends/core/Account.html#getId() getId()]
 +
: [https://www.cse.wustl.edu/~cosgroved/courses/cse231/current/apidocs/mapreduce/apps/friends/core/Account.html#getFriendIds() getFriendIds()]
 +
 +
==AccountId==
 +
[https://www.cse.wustl.edu/~cosgroved/courses/cse231/s20/apidocs/mapreduce/apps/friends/core/AccountId.html class AccountId]
 +
 +
==MutualFriendIds==
 +
[https://www.cse.wustl.edu/~cosgroved/courses/cse231/s20/apidocs/mapreduce/apps/friends/core/MutualFriendIds.html class MutualFriendIds]
 +
: [https://www.cse.wustl.edu/~cosgroved/courses/cse231/s20/apidocs/mapreduce/apps/friends/core/MutualFriendIds.html#createInitializedToUniverse(java.util.Collection) createInitializedToUniverse(universe)]
 +
: [https://www.cse.wustl.edu/~cosgroved/courses/cse231/s20/apidocs/mapreduce/apps/friends/core/MutualFriendIds.html#intersectWith(java.util.Set) intersectWith(friendIds)]
  
 
=Code To Implement=
 
=Code To Implement=
Line 20: Line 34:
 
=Testing Your Solution=
 
=Testing Your Solution=
 
==Correctness==
 
==Correctness==
{{TestSuite|MutualFriendsStudioTestSuite|mapreduce}}
+
{{TestSuite|MutualFriendsStudioTestSuite|mapreduce.apps.friends.studio}}

Latest revision as of 02:50, 25 February 2020

Motivation

Finding mutual friends is a compelling MapReduce App and has a nice write up on the web.

Background

Steve Krenzel Finding Friends

Code To Investigate

Account

class Account

getId()
getFriendIds()

AccountId

class AccountId

MutualFriendIds

class MutualFriendIds

createInitializedToUniverse(universe)
intersectWith(friendIds)

Code To Implement

class: MutualFriendsMapper.java Java.png
methods: map
package: mapreduce.apps.friends.studio
source folder: src/main/java

method: public void map(Account account, BiConsumer<OrderedPair<AccountId>, Set<AccountId>> keyValuePairConsumer) Sequential.svg (sequential implementation only)

The only method you will need to alter is the map method. In this method, you will need to map every combination of the account holder to his/her friends. In order to do this, create ordered pairs of the given account’s ID and the IDs of the account holder’s friends. You must then feed each individual ordered pair into the keyValuePairConsumer along with the full set of the account holder’s friends.

Hint: check out the methods in the Account class for help.

class: MutualFriendsClassicReducer.java Java.png
methods: finisher
package: mapreduce.apps.friends.studio
source folder: src/main/java

method: public Function<List<Set<AccountId>>, MutualFriendIds> finisher() Sequential.svg (sequential implementation only)

Investigate MutualFriendIds for clues on what you need to do.

Testing Your Solution

Correctness

class: MutualFriendsStudioTestSuite.java Junit.png
package: mapreduce.apps.friends.studio
source folder: src/test/java