{"action":"created","comment":{"url":"https://api.github.com/repos/m3db/m3aggregator/pulls/comments/89375569","pull_request_review_id":9921793,"id":89375569,"diff_hunk":"@@ -0,0 +1,79 @@\n+// Copyright (c) 2016 Uber Technologies, Inc.\n+//\n+// Permission is hereby granted, free of charge, to any person obtaining a copy\n+// of this software and associated documentation files (the \"Software\"), to deal\n+// in the Software without restriction, including without limitation the rights\n+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+// copies of the Software, and to permit persons to whom the Software is\n+// furnished to do so, subject to the following conditions:\n+//\n+// The above copyright notice and this permission notice shall be included in\n+// all copies or substantial portions of the Software.\n+//\n+// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+// THE SOFTWARE.\n+\n+package cm\n+\n+type minHeap []float64\n+\n+// Len returns the number of values in the heap\n+func (h minHeap) Len() int { return len(h) }\n+\n+// Min returns the minimum value from the heap\n+func (h minHeap) Min() float64 { return h[0] }\n+\n+// Push pushes a value onto the heap\n+func (h *minHeap) Push(value float64) {\n+\t*h = append(*h, value)\n+\th.shiftUp(h.Len() - 1)\n+}\n+\n+// Pop pops the minimum value from the heap\n+func (h *minHeap) Pop() float64 {\n+\tvar (\n+\t\told = *h\n+\t\tn   = old.Len()\n+\t\tval = old[0]\n+\t)\n+\n+\told[0], old[n-1] = old[n-1], old[0]\n+\th.heapify(0, n-1)\n+\t*h = (*h)[0 : n-1]","path":"quantile/cm/heap.go","position":47,"original_position":47,"commit_id":"876ff939fa48b03a670fb5193959b262b7dcb4ed","original_commit_id":"876ff939fa48b03a670fb5193959b262b7dcb4ed","user":{"login":"xichen2020","id":12239421,"avatar_url":"https://avatars.githubusercontent.com/u/12239421?v=3","gravatar_id":"","url":"https://api.github.com/users/xichen2020","html_url":"https://github.com/xichen2020","followers_url":"https://api.github.com/users/xichen2020/followers","following_url":"https://api.github.com/users/xichen2020/following{/other_user}","gists_url":"https://api.github.com/users/xichen2020/gists{/gist_id}","starred_url":"https://api.github.com/users/xichen2020/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xichen2020/subscriptions","organizations_url":"https://api.github.com/users/xichen2020/orgs","repos_url":"https://api.github.com/users/xichen2020/repos","events_url":"https://api.github.com/users/xichen2020/events{/privacy}","received_events_url":"https://api.github.com/users/xichen2020/received_events","type":"User","site_admin":false},"body":"No it shouldn't, it's just a slice copy","created_at":"2016-11-23T18:36:04Z","updated_at":"2016-11-23T18:36:04Z","html_url":"https://github.com/m3db/m3aggregator/pull/2#discussion_r89375569","pull_request_url":"https://api.github.com/repos/m3db/m3aggregator/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/m3db/m3aggregator/pulls/comments/89375569"},"html":{"href":"https://github.com/m3db/m3aggregator/pull/2#discussion_r89375569"},"pull_request":{"href":"https://api.github.com/repos/m3db/m3aggregator/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/m3db/m3aggregator/pulls/2","id":94674359,"html_url":"https://github.com/m3db/m3aggregator/pull/2","diff_url":"https://github.com/m3db/m3aggregator/pull/2.diff","patch_url":"https://github.com/m3db/m3aggregator/pull/2.patch","issue_url":"https://api.github.com/repos/m3db/m3aggregator/issues/2","number":2,"state":"open","locked":false,"title":"Implementing Cormode-Muthukrishnan algorithm and t-digest algorithm for computing biased quantiles","user":{"login":"xichen2020","id":12239421,"avatar_url":"https://avatars.githubusercontent.com/u/12239421?v=3","gravatar_id":"","url":"https://api.github.com/users/xichen2020","html_url":"https://github.com/xichen2020","followers_url":"https://api.github.com/users/xichen2020/followers","following_url":"https://api.github.com/users/xichen2020/following{/other_user}","gists_url":"https://api.github.com/users/xichen2020/gists{/gist_id}","starred_url":"https://api.github.com/users/xichen2020/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xichen2020/subscriptions","organizations_url":"https://api.github.com/users/xichen2020/orgs","repos_url":"https://api.github.com/users/xichen2020/repos","events_url":"https://api.github.com/users/xichen2020/events{/privacy}","received_events_url":"https://api.github.com/users/xichen2020/received_events","type":"User","site_admin":false},"body":"cc @robskillington @martin-mao @cw9 \r\n\r\nThe Cormode-Muthukrishnan algorithm is what statsite currently uses for estimating quantiles for timers and is generally more accurate when the number of samples is small. However the algorithm (and the underlying data structure in the implementation) does not allow merging, which means it can only consume raw data points and uses more network bandwidth.\r\n\r\nThe t-digest algorithm is slightly less accurate when the number of samples is small (e.g., < 100). Additionally it doesn't guarantee the estimate is always one of the values in the provided data stream since it's based on clustering and interpolation. However it does show similar accuracy when the number of samples is large. More importantly, it supports merging naturally.\r\n\r\nThis PR implements the Cormode-Muthukrishnan algorithm and t-digest algorithm for computing biased quantiles. Depending on the accuracy and bandwidth requirements, we can adopt one or the other, or a hybrid of both.","created_at":"2016-11-21T18:54:13Z","updated_at":"2016-11-23T18:36:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d6e2485a2d23ea7ca8e0e51a5ef4862c0f2e60f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/m3db/m3aggregator/pulls/2/commits","review_comments_url":"https://api.github.com/repos/m3db/m3aggregator/pulls/2/comments","review_comment_url":"https://api.github.com/repos/m3db/m3aggregator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/m3db/m3aggregator/issues/2/comments","statuses_url":"https://api.github.com/repos/m3db/m3aggregator/statuses/876ff939fa48b03a670fb5193959b262b7dcb4ed","head":{"label":"m3db:xichen-pooling-quantile-cm","ref":"xichen-pooling-quantile-cm","sha":"876ff939fa48b03a670fb5193959b262b7dcb4ed","user":{"login":"m3db","id":19937171,"avatar_url":"https://avatars.githubusercontent.com/u/19937171?v=3","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":74390805,"name":"m3aggregator","full_name":"m3db/m3aggregator","owner":{"login":"m3db","id":19937171,"avatar_url":"https://avatars.githubusercontent.com/u/19937171?v=3","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m3db/m3aggregator","description":"Metrics aggregation server","fork":false,"url":"https://api.github.com/repos/m3db/m3aggregator","forks_url":"https://api.github.com/repos/m3db/m3aggregator/forks","keys_url":"https://api.github.com/repos/m3db/m3aggregator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/m3aggregator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/m3aggregator/teams","hooks_url":"https://api.github.com/repos/m3db/m3aggregator/hooks","issue_events_url":"https://api.github.com/repos/m3db/m3aggregator/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/m3aggregator/events","assignees_url":"https://api.github.com/repos/m3db/m3aggregator/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/m3aggregator/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/m3aggregator/tags","blobs_url":"https://api.github.com/repos/m3db/m3aggregator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/m3aggregator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/m3aggregator/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/m3aggregator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/m3aggregator/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/m3aggregator/languages","stargazers_url":"https://api.github.com/repos/m3db/m3aggregator/stargazers","contributors_url":"https://api.github.com/repos/m3db/m3aggregator/contributors","subscribers_url":"https://api.github.com/repos/m3db/m3aggregator/subscribers","subscription_url":"https://api.github.com/repos/m3db/m3aggregator/subscription","commits_url":"https://api.github.com/repos/m3db/m3aggregator/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/m3aggregator/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/m3aggregator/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/m3aggregator/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/m3aggregator/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/m3aggregator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/m3aggregator/merges","archive_url":"https://api.github.com/repos/m3db/m3aggregator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/m3aggregator/downloads","issues_url":"https://api.github.com/repos/m3db/m3aggregator/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/m3aggregator/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/m3aggregator/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/m3aggregator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/m3aggregator/labels{/name}","releases_url":"https://api.github.com/repos/m3db/m3aggregator/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/m3aggregator/deployments","created_at":"2016-11-21T17:58:46Z","updated_at":"2016-11-21T18:39:11Z","pushed_at":"2016-11-23T15:47:16Z","git_url":"git://github.com/m3db/m3aggregator.git","ssh_url":"git@github.com:m3db/m3aggregator.git","clone_url":"https://github.com/m3db/m3aggregator.git","svn_url":"https://github.com/m3db/m3aggregator","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"m3db:master","ref":"master","sha":"d8e60bb42ea6b21dc725af0e1f8864d82040498b","user":{"login":"m3db","id":19937171,"avatar_url":"https://avatars.githubusercontent.com/u/19937171?v=3","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":74390805,"name":"m3aggregator","full_name":"m3db/m3aggregator","owner":{"login":"m3db","id":19937171,"avatar_url":"https://avatars.githubusercontent.com/u/19937171?v=3","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m3db/m3aggregator","description":"Metrics aggregation server","fork":false,"url":"https://api.github.com/repos/m3db/m3aggregator","forks_url":"https://api.github.com/repos/m3db/m3aggregator/forks","keys_url":"https://api.github.com/repos/m3db/m3aggregator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/m3aggregator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/m3aggregator/teams","hooks_url":"https://api.github.com/repos/m3db/m3aggregator/hooks","issue_events_url":"https://api.github.com/repos/m3db/m3aggregator/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/m3aggregator/events","assignees_url":"https://api.github.com/repos/m3db/m3aggregator/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/m3aggregator/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/m3aggregator/tags","blobs_url":"https://api.github.com/repos/m3db/m3aggregator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/m3aggregator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/m3aggregator/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/m3aggregator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/m3aggregator/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/m3aggregator/languages","stargazers_url":"https://api.github.com/repos/m3db/m3aggregator/stargazers","contributors_url":"https://api.github.com/repos/m3db/m3aggregator/contributors","subscribers_url":"https://api.github.com/repos/m3db/m3aggregator/subscribers","subscription_url":"https://api.github.com/repos/m3db/m3aggregator/subscription","commits_url":"https://api.github.com/repos/m3db/m3aggregator/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/m3aggregator/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/m3aggregator/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/m3aggregator/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/m3aggregator/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/m3aggregator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/m3aggregator/merges","archive_url":"https://api.github.com/repos/m3db/m3aggregator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/m3aggregator/downloads","issues_url":"https://api.github.com/repos/m3db/m3aggregator/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/m3aggregator/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/m3aggregator/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/m3aggregator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/m3aggregator/labels{/name}","releases_url":"https://api.github.com/repos/m3db/m3aggregator/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/m3aggregator/deployments","created_at":"2016-11-21T17:58:46Z","updated_at":"2016-11-21T18:39:11Z","pushed_at":"2016-11-23T15:47:16Z","git_url":"git://github.com/m3db/m3aggregator.git","ssh_url":"git@github.com:m3db/m3aggregator.git","clone_url":"https://github.com/m3db/m3aggregator.git","svn_url":"https://github.com/m3db/m3aggregator","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/m3db/m3aggregator/pulls/2"},"html":{"href":"https://github.com/m3db/m3aggregator/pull/2"},"issue":{"href":"https://api.github.com/repos/m3db/m3aggregator/issues/2"},"comments":{"href":"https://api.github.com/repos/m3db/m3aggregator/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/m3db/m3aggregator/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/m3db/m3aggregator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/m3db/m3aggregator/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/m3db/m3aggregator/statuses/876ff939fa48b03a670fb5193959b262b7dcb4ed"}}}}
{"actor":{"display_login":"xichen2020"}}