Mutual Friends MapReduce Application

From CSE231 Wiki
Revision as of 04:56, 5 March 2023 by Cosgroved (talk | contribs) (→‎Testing Your Solution)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Motivation

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

Background

Steve Krenzel Finding Friends

Be sure to complete the [[Set_Intersector_Assignment|SetIntersector<E>] warmup before starting this exercise.

Code To Investigate

Account

class Account

getId()
getFriendIds()

AccountId

class AccountId

SetIntersector<E>

class SetIntersector<E>

accept(friendIds)
currentIntersection()

Code To Implement

MutualFriendsMapper

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

method: public List<Map.Entry<OrderedPair<AccountId>, Set<AccountId>>> map(Account account) Sequential.svg (sequential implementation only)

The only method you will need to alter (and the only method in this class) is the map method. In this method, you will need to map every combination of the account holder to their friends. In order to do this, create OrderedPairs of the given account’s ID and the IDs of the account holder’s friends. For each ordered pair, you should provide the pair along with the full set of IDs of the account holder's friends.

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

MutualFriendsReducer

class: MutualFriendsClassicReducer.java Java.png
methods: reduce
package: mapreduce.apps.friends.exercise
source folder: student/src/main/java

method: public Set<AccountId> reduce(List<Set<AccountId>> container) Sequential.svg (sequential implementation only)

SetIntersector can be used to calculate the set intersection. Invoke accept(set) for each set in the <container> parameter, then invoke currentIntersection() to get the result.

Testing Your Solution

Correctness

class: _MutualFriendsTestSuite.java Junit.png
package: mapreduce
source folder: testing/src/test/java

Pledge, Acknowledgments, Citations

file: map-reduce-mutual-friends-app-pledge-acknowledgments-citations.txt

More info about the Honor Pledge