Created
February 18, 2018 20:46
-
-
Save vardanator/0d026eae46eed02ff27c1219f6e91ee9 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
| // Warning: a bunch of pseudocode ahead | |
| void RangeInsertIntoTimelines(vector<long> user_ids, long tweet_id) | |
| { | |
| for (auto id : user_ids) { | |
| InsertIntoUserTimeline(id, tweet_id); | |
| } | |
| } | |
| void DeliverATweet(User* author, Tweet* tw) | |
| { | |
| // we assume that 'tw' object is already stored in a database | |
| // 1. Get the list of user's (tweet author's) followers's ids | |
| vector<long> user_followers = GetUserFollowers(author->id); | |
| // 2. Insert tweet into each timeline in parallel | |
| const int CHUNK_SIZE = 4000; // saw this somewhere | |
| for (each CHUNK_SIZE elements in user_followers) { | |
| Thread t = ThreadPool.GetAvailableThread(); // somehow | |
| t.Run(RangeInsertIntoTimelines, current_chunk, tw->id); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment