{"action":"created","comment":{"url":"https://api.github.com/repos/koding/koding/pulls/comments/99347527","pull_request_review_id":20023307,"id":99347527,"diff_hunk":"@@ -0,0 +1,163 @@\n+package index\n+\n+import (\n+\t\"sync/atomic\"\n+\t\"time\"\n+)\n+\n+// ChangeMeta indicates what change has been done on a given file.\n+type ChangeMeta uint64\n+\n+const (\n+\tChangeMetaLocal  ChangeMeta = 1 << iota // local->remote synchronization.\n+\tChangeMetaRemote                        // remote->local synchronization.\n+\tChangeMetaAdd                           // File was added.\n+\tChangeMetaRemove                        // File was removed.\n+\tChangeMetaUpdate                        // File was updated.\n+\tChangeMetaLarge                         // File size is above 4GB.\n+)\n+\n+// Followed constants are helpers for ChangeMeta.Coalesce method.\n+const (\n+\tcmInv = 0\n+\tcmEv  = ChangeMetaUpdate | ChangeMetaRemove | ChangeMetaAdd\n+\tcmAll = cmEv | ChangeMetaRemote | ChangeMetaLocal\n+\n+\tcmUL = ChangeMetaUpdate | ChangeMetaLocal\n+\tcmDL = ChangeMetaRemove | ChangeMetaLocal\n+\tcmAL = ChangeMetaAdd | ChangeMetaLocal\n+\n+\tcmUR = ChangeMetaUpdate | ChangeMetaRemote\n+\tcmDR = ChangeMetaRemove | ChangeMetaRemote\n+\tcmAR = ChangeMetaAdd | ChangeMetaRemote\n+)\n+\n+// udarlMap is a helper array used to map coalesced changes to new change. It\n+// has all((3+2)^5) combinations of UDA events and RL directions.\n+var udarlMap = [32]ChangeMeta{\n+\tcmInv, cmInv, cmInv, cmInv,\n+\tcmAL, cmAL, cmAR, cmUL,\n+\tcmDL, cmDL, cmDR, cmDL,\n+\tcmUL, cmUL, cmUR, cmAll,\n+\tcmUL, cmUL, cmUR, cmUL,\n+\tcmAL, cmAL, cmAR, cmUL,\n+\tcmDL, cmDL, cmDR, cmAll,\n+\tcmInv, cmInv, cmInv, cmInv,\n+}\n+\n+// Coalesce coalesces two meta-data changes and saves the result to called\n+// object. The rules of coalescing are:\n+//\n+//  U - update; D - remove(delete); A - add; L - local; R - remote.\n+//\n+//      | UL | DL | AL | UR | DR | AR |\n+//      +----+----+----+----+----+----+----\n+//      | UL | DL | AL | UL | AL | UL | UL\n+//      +----+----+----+----+----+----+----\n+//           | DL | UL | DL | DL | DL | DL\n+//           +----+----+----+----+----+----\n+//                | AL | UL | AL | UL | AL\n+//                +----+----+----+----+----\n+//                     | UR | DR | AR | UR\n+//                     +----+----+----+----\n+//                          | DR | UR | DR\n+//                          +----+----+----\n+//                               | AR | AR\n+//                               +----+----\n+//\n+// Example: If add remote change(AR) is merged with update local (UL) change,\n+//          the coalesced event will be update local AR+UL=UL. This means that\n+//          local updated file should overwrite remotely added one.\n+//\n+// All other flags are OR-ed. The coalesce matrix must be kept triangular.\n+func (cm *ChangeMeta) Coalesce(newer ChangeMeta) {\n+\tfor {\n+\t\tolder := ChangeMeta(atomic.LoadUint64((*uint64)(cm)))\n+\n+\t\tpartial := udarlMap[(older|newer)&31]","path":"go/src/koding/klient/machine/index/change.go","position":77,"original_position":77,"commit_id":"c60be57f9783f381b25f8d65eeb467bd70a17ab5","original_commit_id":"c60be57f9783f381b25f8d65eeb467bd70a17ab5","user":{"login":"cihangir","id":879660,"avatar_url":"https://avatars.githubusercontent.com/u/879660?v=3","gravatar_id":"","url":"https://api.github.com/users/cihangir","html_url":"https://github.com/cihangir","followers_url":"https://api.github.com/users/cihangir/followers","following_url":"https://api.github.com/users/cihangir/following{/other_user}","gists_url":"https://api.github.com/users/cihangir/gists{/gist_id}","starred_url":"https://api.github.com/users/cihangir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cihangir/subscriptions","organizations_url":"https://api.github.com/users/cihangir/orgs","repos_url":"https://api.github.com/users/cihangir/repos","events_url":"https://api.github.com/users/cihangir/events{/privacy}","received_events_url":"https://api.github.com/users/cihangir/received_events","type":"User","site_admin":false},"body":"could you document why do you AND with 31","created_at":"2017-02-03T14:34:26Z","updated_at":"2017-02-03T14:39:56Z","html_url":"https://github.com/koding/koding/pull/10487#discussion_r99347527","pull_request_url":"https://api.github.com/repos/koding/koding/pulls/10487","_links":{"self":{"href":"https://api.github.com/repos/koding/koding/pulls/comments/99347527"},"html":{"href":"https://github.com/koding/koding/pull/10487#discussion_r99347527"},"pull_request":{"href":"https://api.github.com/repos/koding/koding/pulls/10487"}}},"pull_request":{"url":"https://api.github.com/repos/koding/koding/pulls/10487","id":104478132,"html_url":"https://github.com/koding/koding/pull/10487","diff_url":"https://github.com/koding/koding/pull/10487.diff","patch_url":"https://github.com/koding/koding/pull/10487.patch","issue_url":"https://api.github.com/repos/koding/koding/issues/10487","number":10487,"state":"open","locked":false,"title":"Lock-free index Change coalescing logic.","user":{"login":"ppknap","id":5021246,"avatar_url":"https://avatars.githubusercontent.com/u/5021246?v=3","gravatar_id":"","url":"https://api.github.com/users/ppknap","html_url":"https://github.com/ppknap","followers_url":"https://api.github.com/users/ppknap/followers","following_url":"https://api.github.com/users/ppknap/following{/other_user}","gists_url":"https://api.github.com/users/ppknap/gists{/gist_id}","starred_url":"https://api.github.com/users/ppknap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppknap/subscriptions","organizations_url":"https://api.github.com/users/ppknap/orgs","repos_url":"https://api.github.com/users/ppknap/repos","events_url":"https://api.github.com/users/ppknap/events{/privacy}","received_events_url":"https://api.github.com/users/ppknap/received_events","type":"User","site_admin":false},"body":"This PR adds logic required by syncer when more than one FS change describing identical file came to synchronization queue. Local machine changes have higher priority than remote ones.\r\n\r\nSee `ChangeMeta.Coalesce` method comment for more information.\r\n\r\n## How Has This Been Tested?\r\nUnit tests\r\n\r\n## Types of changes\r\n- [x] New feature (non-breaking change which adds functionality)\r\n\r\n","created_at":"2017-02-03T05:33:54Z","updated_at":"2017-02-03T14:39:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c0c123117188efc6b1e54206db4d5b7c906a68f2","assignee":{"login":"cihangir","id":879660,"avatar_url":"https://avatars.githubusercontent.com/u/879660?v=3","gravatar_id":"","url":"https://api.github.com/users/cihangir","html_url":"https://github.com/cihangir","followers_url":"https://api.github.com/users/cihangir/followers","following_url":"https://api.github.com/users/cihangir/following{/other_user}","gists_url":"https://api.github.com/users/cihangir/gists{/gist_id}","starred_url":"https://api.github.com/users/cihangir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cihangir/subscriptions","organizations_url":"https://api.github.com/users/cihangir/orgs","repos_url":"https://api.github.com/users/cihangir/repos","events_url":"https://api.github.com/users/cihangir/events{/privacy}","received_events_url":"https://api.github.com/users/cihangir/received_events","type":"User","site_admin":false},"assignees":[{"login":"cihangir","id":879660,"avatar_url":"https://avatars.githubusercontent.com/u/879660?v=3","gravatar_id":"","url":"https://api.github.com/users/cihangir","html_url":"https://github.com/cihangir","followers_url":"https://api.github.com/users/cihangir/followers","following_url":"https://api.github.com/users/cihangir/following{/other_user}","gists_url":"https://api.github.com/users/cihangir/gists{/gist_id}","starred_url":"https://api.github.com/users/cihangir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cihangir/subscriptions","organizations_url":"https://api.github.com/users/cihangir/orgs","repos_url":"https://api.github.com/users/cihangir/repos","events_url":"https://api.github.com/users/cihangir/events{/privacy}","received_events_url":"https://api.github.com/users/cihangir/received_events","type":"User","site_admin":false},{"login":"rjeczalik","id":1162017,"avatar_url":"https://avatars.githubusercontent.com/u/1162017?v=3","gravatar_id":"","url":"https://api.github.com/users/rjeczalik","html_url":"https://github.com/rjeczalik","followers_url":"https://api.github.com/users/rjeczalik/followers","following_url":"https://api.github.com/users/rjeczalik/following{/other_user}","gists_url":"https://api.github.com/users/rjeczalik/gists{/gist_id}","starred_url":"https://api.github.com/users/rjeczalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjeczalik/subscriptions","organizations_url":"https://api.github.com/users/rjeczalik/orgs","repos_url":"https://api.github.com/users/rjeczalik/repos","events_url":"https://api.github.com/users/rjeczalik/events{/privacy}","received_events_url":"https://api.github.com/users/rjeczalik/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/koding/koding/pulls/10487/commits","review_comments_url":"https://api.github.com/repos/koding/koding/pulls/10487/comments","review_comment_url":"https://api.github.com/repos/koding/koding/pulls/comments{/number}","comments_url":"https://api.github.com/repos/koding/koding/issues/10487/comments","statuses_url":"https://api.github.com/repos/koding/koding/statuses/c60be57f9783f381b25f8d65eeb467bd70a17ab5","head":{"label":"koding:machine_index_coalesce","ref":"machine_index_coalesce","sha":"c60be57f9783f381b25f8d65eeb467bd70a17ab5","user":{"login":"koding","id":1066754,"avatar_url":"https://avatars.githubusercontent.com/u/1066754?v=3","gravatar_id":"","url":"https://api.github.com/users/koding","html_url":"https://github.com/koding","followers_url":"https://api.github.com/users/koding/followers","following_url":"https://api.github.com/users/koding/following{/other_user}","gists_url":"https://api.github.com/users/koding/gists{/gist_id}","starred_url":"https://api.github.com/users/koding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koding/subscriptions","organizations_url":"https://api.github.com/users/koding/orgs","repos_url":"https://api.github.com/users/koding/repos","events_url":"https://api.github.com/users/koding/events{/privacy}","received_events_url":"https://api.github.com/users/koding/received_events","type":"Organization","site_admin":false},"repo":{"id":21317360,"name":"koding","full_name":"koding/koding","owner":{"login":"koding","id":1066754,"avatar_url":"https://avatars.githubusercontent.com/u/1066754?v=3","gravatar_id":"","url":"https://api.github.com/users/koding","html_url":"https://github.com/koding","followers_url":"https://api.github.com/users/koding/followers","following_url":"https://api.github.com/users/koding/following{/other_user}","gists_url":"https://api.github.com/users/koding/gists{/gist_id}","starred_url":"https://api.github.com/users/koding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koding/subscriptions","organizations_url":"https://api.github.com/users/koding/orgs","repos_url":"https://api.github.com/users/koding/repos","events_url":"https://api.github.com/users/koding/events{/privacy}","received_events_url":"https://api.github.com/users/koding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/koding/koding","description":"The Simplest Way to Manage Your Entire Dev Infrastructure!","fork":false,"url":"https://api.github.com/repos/koding/koding","forks_url":"https://api.github.com/repos/koding/koding/forks","keys_url":"https://api.github.com/repos/koding/koding/keys{/key_id}","collaborators_url":"https://api.github.com/repos/koding/koding/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/koding/koding/teams","hooks_url":"https://api.github.com/repos/koding/koding/hooks","issue_events_url":"https://api.github.com/repos/koding/koding/issues/events{/number}","events_url":"https://api.github.com/repos/koding/koding/events","assignees_url":"https://api.github.com/repos/koding/koding/assignees{/user}","branches_url":"https://api.github.com/repos/koding/koding/branches{/branch}","tags_url":"https://api.github.com/repos/koding/koding/tags","blobs_url":"https://api.github.com/repos/koding/koding/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/koding/koding/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/koding/koding/git/refs{/sha}","trees_url":"https://api.github.com/repos/koding/koding/git/trees{/sha}","statuses_url":"https://api.github.com/repos/koding/koding/statuses/{sha}","languages_url":"https://api.github.com/repos/koding/koding/languages","stargazers_url":"https://api.github.com/repos/koding/koding/stargazers","contributors_url":"https://api.github.com/repos/koding/koding/contributors","subscribers_url":"https://api.github.com/repos/koding/koding/subscribers","subscription_url":"https://api.github.com/repos/koding/koding/subscription","commits_url":"https://api.github.com/repos/koding/koding/commits{/sha}","git_commits_url":"https://api.github.com/repos/koding/koding/git/commits{/sha}","comments_url":"https://api.github.com/repos/koding/koding/comments{/number}","issue_comment_url":"https://api.github.com/repos/koding/koding/issues/comments{/number}","contents_url":"https://api.github.com/repos/koding/koding/contents/{+path}","compare_url":"https://api.github.com/repos/koding/koding/compare/{base}...{head}","merges_url":"https://api.github.com/repos/koding/koding/merges","archive_url":"https://api.github.com/repos/koding/koding/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/koding/koding/downloads","issues_url":"https://api.github.com/repos/koding/koding/issues{/number}","pulls_url":"https://api.github.com/repos/koding/koding/pulls{/number}","milestones_url":"https://api.github.com/repos/koding/koding/milestones{/number}","notifications_url":"https://api.github.com/repos/koding/koding/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/koding/koding/labels{/name}","releases_url":"https://api.github.com/repos/koding/koding/releases{/id}","deployments_url":"https://api.github.com/repos/koding/koding/deployments","created_at":"2014-06-29T05:46:24Z","updated_at":"2017-02-03T09:04:00Z","pushed_at":"2017-02-03T14:02:38Z","git_url":"git://github.com/koding/koding.git","ssh_url":"git@github.com:koding/koding.git","clone_url":"https://github.com/koding/koding.git","svn_url":"https://github.com/koding/koding","homepage":"https://www.koding.com","size":829827,"stargazers_count":538,"watchers_count":538,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":75,"mirror_url":null,"open_issues_count":239,"forks":75,"open_issues":239,"watchers":538,"default_branch":"master"}},"base":{"label":"koding:master","ref":"master","sha":"0635d40730e6a39ae5029dbb5bcd314ebdaec7d9","user":{"login":"koding","id":1066754,"avatar_url":"https://avatars.githubusercontent.com/u/1066754?v=3","gravatar_id":"","url":"https://api.github.com/users/koding","html_url":"https://github.com/koding","followers_url":"https://api.github.com/users/koding/followers","following_url":"https://api.github.com/users/koding/following{/other_user}","gists_url":"https://api.github.com/users/koding/gists{/gist_id}","starred_url":"https://api.github.com/users/koding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koding/subscriptions","organizations_url":"https://api.github.com/users/koding/orgs","repos_url":"https://api.github.com/users/koding/repos","events_url":"https://api.github.com/users/koding/events{/privacy}","received_events_url":"https://api.github.com/users/koding/received_events","type":"Organization","site_admin":false},"repo":{"id":21317360,"name":"koding","full_name":"koding/koding","owner":{"login":"koding","id":1066754,"avatar_url":"https://avatars.githubusercontent.com/u/1066754?v=3","gravatar_id":"","url":"https://api.github.com/users/koding","html_url":"https://github.com/koding","followers_url":"https://api.github.com/users/koding/followers","following_url":"https://api.github.com/users/koding/following{/other_user}","gists_url":"https://api.github.com/users/koding/gists{/gist_id}","starred_url":"https://api.github.com/users/koding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koding/subscriptions","organizations_url":"https://api.github.com/users/koding/orgs","repos_url":"https://api.github.com/users/koding/repos","events_url":"https://api.github.com/users/koding/events{/privacy}","received_events_url":"https://api.github.com/users/koding/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/koding/koding","description":"The Simplest Way to Manage Your Entire Dev Infrastructure!","fork":false,"url":"https://api.github.com/repos/koding/koding","forks_url":"https://api.github.com/repos/koding/koding/forks","keys_url":"https://api.github.com/repos/koding/koding/keys{/key_id}","collaborators_url":"https://api.github.com/repos/koding/koding/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/koding/koding/teams","hooks_url":"https://api.github.com/repos/koding/koding/hooks","issue_events_url":"https://api.github.com/repos/koding/koding/issues/events{/number}","events_url":"https://api.github.com/repos/koding/koding/events","assignees_url":"https://api.github.com/repos/koding/koding/assignees{/user}","branches_url":"https://api.github.com/repos/koding/koding/branches{/branch}","tags_url":"https://api.github.com/repos/koding/koding/tags","blobs_url":"https://api.github.com/repos/koding/koding/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/koding/koding/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/koding/koding/git/refs{/sha}","trees_url":"https://api.github.com/repos/koding/koding/git/trees{/sha}","statuses_url":"https://api.github.com/repos/koding/koding/statuses/{sha}","languages_url":"https://api.github.com/repos/koding/koding/languages","stargazers_url":"https://api.github.com/repos/koding/koding/stargazers","contributors_url":"https://api.github.com/repos/koding/koding/contributors","subscribers_url":"https://api.github.com/repos/koding/koding/subscribers","subscription_url":"https://api.github.com/repos/koding/koding/subscription","commits_url":"https://api.github.com/repos/koding/koding/commits{/sha}","git_commits_url":"https://api.github.com/repos/koding/koding/git/commits{/sha}","comments_url":"https://api.github.com/repos/koding/koding/comments{/number}","issue_comment_url":"https://api.github.com/repos/koding/koding/issues/comments{/number}","contents_url":"https://api.github.com/repos/koding/koding/contents/{+path}","compare_url":"https://api.github.com/repos/koding/koding/compare/{base}...{head}","merges_url":"https://api.github.com/repos/koding/koding/merges","archive_url":"https://api.github.com/repos/koding/koding/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/koding/koding/downloads","issues_url":"https://api.github.com/repos/koding/koding/issues{/number}","pulls_url":"https://api.github.com/repos/koding/koding/pulls{/number}","milestones_url":"https://api.github.com/repos/koding/koding/milestones{/number}","notifications_url":"https://api.github.com/repos/koding/koding/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/koding/koding/labels{/name}","releases_url":"https://api.github.com/repos/koding/koding/releases{/id}","deployments_url":"https://api.github.com/repos/koding/koding/deployments","created_at":"2014-06-29T05:46:24Z","updated_at":"2017-02-03T09:04:00Z","pushed_at":"2017-02-03T14:02:38Z","git_url":"git://github.com/koding/koding.git","ssh_url":"git@github.com:koding/koding.git","clone_url":"https://github.com/koding/koding.git","svn_url":"https://github.com/koding/koding","homepage":"https://www.koding.com","size":829827,"stargazers_count":538,"watchers_count":538,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":75,"mirror_url":null,"open_issues_count":239,"forks":75,"open_issues":239,"watchers":538,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/koding/koding/pulls/10487"},"html":{"href":"https://github.com/koding/koding/pull/10487"},"issue":{"href":"https://api.github.com/repos/koding/koding/issues/10487"},"comments":{"href":"https://api.github.com/repos/koding/koding/issues/10487/comments"},"review_comments":{"href":"https://api.github.com/repos/koding/koding/pulls/10487/comments"},"review_comment":{"href":"https://api.github.com/repos/koding/koding/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/koding/koding/pulls/10487/commits"},"statuses":{"href":"https://api.github.com/repos/koding/koding/statuses/c60be57f9783f381b25f8d65eeb467bd70a17ab5"}}}}
{"actor":{"display_login":"cihangir"}}