Guest User

Untitled

a guest
Nov 23rd, 2017
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class shitty project extends Reducer<Text, Text, Text, Text> {
  4.  
  5. private Text friendList = new Text();
  6.  
  7. @Override
  8. public void reduce(final Text key, final Iterable<Text> values, final Context context) throws IOException, InterruptedException {
  9.  
  10. ArrayList commonFriends = new ArrayList();
  11.  
  12. if(values.size()!=2) System.out.println("Error");
  13. else{
  14. StringTokenizer list1 = new StringTokenizer(values[0].toString());
  15. StringTokenizer list2 = new StringTokenizer(values[1].toString());
  16. while (list1.hasMoreTokens()) {
  17. friend1=list1.nextToken();
  18. while (list2.hasMoreTokens()) {
  19. friend2=list2.nextToken();
  20. if(friend1==friend2) commonFriends(friend1);
  21. }
  22. }
  23. }
  24. friendList.set(commonFriends);
  25. context.write(key, friendList);
  26. }
  27. }
Add Comment
Please, Sign In to add comment