Last active
April 2, 2018 12:51
-
-
Save deque-blog/cdbdbc202e31abd70186fa1b7d33c219 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Iterable<PostSummary> suggestedPostsFor(ProfileId profileId) { | |
try { | |
Future<Iterable<ProfileId>> friendIds = friendsOf(profileId); | |
Set<Topic> topics = favoriteTopicsOf(profileId).get(); | |
Stream<PostSummary> interestingPosts = stream(friendIds.get()) | |
.parallel() // Stream parallelization | |
.flatMap(friendId -> lastPostsOf(friendId)) | |
.filter(post -> post.isAbout(topics)); | |
return mostLiked(3, interestingPosts); | |
} catch (Exception e) { // InterruptedException and ExecutionException | |
// Raise high level abstract error? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment