Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class shitty project extends Reducer<Text, Text, Text, Text> {
- private Text friendList = new Text();
- @Override
- public void reduce(final Text key, final Iterable<Text> values, final Context context) throws IOException, InterruptedException {
- ArrayList commonFriends = new ArrayList();
- if(values.size()!=2) System.out.println("Error");
- else{
- StringTokenizer list1 = new StringTokenizer(values[0].toString());
- StringTokenizer list2 = new StringTokenizer(values[1].toString());
- while (list1.hasMoreTokens()) {
- friend1=list1.nextToken();
- while (list2.hasMoreTokens()) {
- friend2=list2.nextToken();
- if(friend1==friend2) commonFriends(friend1);
- }
- }
- }
- Collection<String> allValues= commonFriends.values();
- java.lang.String entireText = StringUtils.join(allValues, ',');
- friendList.set(entireText);
- context.write(key, friendList);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment