{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/comments/99734480","pull_request_review_id":20419510,"id":99734480,"diff_hunk":"@@ -486,14 +480,163 @@ fn get_chunk(chunks: &mut Vec<Chunk>) -> &mut Chunk {\n     chunks.last_mut().unwrap()\n }\n \n+#[inline]\n+fn encode_row_from_cols(cols: &[ColumnInfo],\n+                        h: i64,\n+                        values: HashMap<i64, &[u8]>,\n+                        data: &mut Vec<u8>)\n+                        -> Result<()> {\n+    for col in cols {\n+        let col_id = col.get_column_id();\n+        if let Some(v) = values.get(&col_id) {\n+            data.extend_from_slice(v);\n+            continue;\n+        }\n+        if col.get_pk_handle() {\n+            box_try!(datum::encode_to(data, &[get_pk(col, h)], false));\n+        } else if mysql::has_not_null_flag(col.get_flag() as u64) {\n+            return Err(box_err!(\"column {} of {} is missing\", col_id, h));\n+        } else {\n+            box_try!(datum::encode_to(data, &[Datum::Null], false));\n+        }\n+    }\n+    Ok(())\n+}\n+\n+#[derive(Debug, Clone)]\n+struct SortRow {\n+    key: Vec<Datum>,\n+    handle: i64,\n+    data: Vec<u8>,\n+    order_cols: Vec<ByItem>,\n+    ctx: Rc<EvalContext>,\n+}\n+\n+\n+impl SortRow {\n+    fn new(handle: i64,\n+           order_cols: Vec<ByItem>,\n+           ctx: Rc<EvalContext>,\n+           data: Vec<u8>,\n+           key: Vec<Datum>)\n+           -> SortRow {\n+        SortRow {\n+            key: key,\n+            handle: handle,\n+            data: data,\n+            order_cols: order_cols,\n+            ctx: ctx,\n+        }\n+    }\n+\n+    fn cmp_and_check(&self, right: &SortRow) -> Result<CmpOrdering> {\n+        let values = self.key.iter().zip(right.key.iter());","path":"src/server/coprocessor/endpoint.rs","position":99,"original_position":99,"commit_id":"8b8e57e9f5e5d3b70d2b30774042738b076521c0","original_commit_id":"8b8e57e9f5e5d3b70d2b30774042738b076521c0","user":{"login":"siddontang","id":1080370,"avatar_url":"https://avatars.githubusercontent.com/u/1080370?v=3","gravatar_id":"","url":"https://api.github.com/users/siddontang","html_url":"https://github.com/siddontang","followers_url":"https://api.github.com/users/siddontang/followers","following_url":"https://api.github.com/users/siddontang/following{/other_user}","gists_url":"https://api.github.com/users/siddontang/gists{/gist_id}","starred_url":"https://api.github.com/users/siddontang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siddontang/subscriptions","organizations_url":"https://api.github.com/users/siddontang/orgs","repos_url":"https://api.github.com/users/siddontang/repos","events_url":"https://api.github.com/users/siddontang/events{/privacy}","received_events_url":"https://api.github.com/users/siddontang/received_events","type":"User","site_admin":false},"body":"refer https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.zip\r\n\r\nIf counts are not equal, zip will ignore extract items and return None.","created_at":"2017-02-07T02:42:50Z","updated_at":"2017-02-07T02:42:50Z","html_url":"https://github.com/pingcap/tikv/pull/1578#discussion_r99734480","pull_request_url":"https://api.github.com/repos/pingcap/tikv/pulls/1578","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments/99734480"},"html":{"href":"https://github.com/pingcap/tikv/pull/1578#discussion_r99734480"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1578"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/1578","id":104650952,"html_url":"https://github.com/pingcap/tikv/pull/1578","diff_url":"https://github.com/pingcap/tikv/pull/1578.diff","patch_url":"https://github.com/pingcap/tikv/pull/1578.patch","issue_url":"https://api.github.com/repos/pingcap/tikv/issues/1578","number":1578,"state":"open","locked":false,"title":"coprocessor:implement topn for select","user":{"login":"AndreMouche","id":1085697,"avatar_url":"https://avatars.githubusercontent.com/u/1085697?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreMouche","html_url":"https://github.com/AndreMouche","followers_url":"https://api.github.com/users/AndreMouche/followers","following_url":"https://api.github.com/users/AndreMouche/following{/other_user}","gists_url":"https://api.github.com/users/AndreMouche/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreMouche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreMouche/subscriptions","organizations_url":"https://api.github.com/users/AndreMouche/orgs","repos_url":"https://api.github.com/users/AndreMouche/repos","events_url":"https://api.github.com/users/AndreMouche/events{/privacy}","received_events_url":"https://api.github.com/users/AndreMouche/received_events","type":"User","site_admin":false},"body":"@BusyJay @disksing PTAL","created_at":"2017-02-04T06:13:55Z","updated_at":"2017-02-07T02:42:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b93660f573f3e9aba03f11baa23393fd3dd2141","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tikv/pulls/1578/commits","review_comments_url":"https://api.github.com/repos/pingcap/tikv/pulls/1578/comments","review_comment_url":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tikv/issues/1578/comments","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/8b8e57e9f5e5d3b70d2b30774042738b076521c0","head":{"label":"pingcap:shirly/coprocessor_topn","ref":"shirly/coprocessor_topn","sha":"8b8e57e9f5e5d3b70d2b30774042738b076521c0","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":48833910,"name":"tikv","full_name":"pingcap/tikv","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":false,"url":"https://api.github.com/repos/pingcap/tikv","forks_url":"https://api.github.com/repos/pingcap/tikv/forks","keys_url":"https://api.github.com/repos/pingcap/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tikv/teams","hooks_url":"https://api.github.com/repos/pingcap/tikv/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tikv/events","assignees_url":"https://api.github.com/repos/pingcap/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tikv/tags","blobs_url":"https://api.github.com/repos/pingcap/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tikv/languages","stargazers_url":"https://api.github.com/repos/pingcap/tikv/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tikv/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tikv/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tikv/subscription","commits_url":"https://api.github.com/repos/pingcap/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tikv/merges","archive_url":"https://api.github.com/repos/pingcap/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tikv/downloads","issues_url":"https://api.github.com/repos/pingcap/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tikv/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tikv/deployments","created_at":"2015-12-31T04:51:32Z","updated_at":"2017-02-06T13:33:19Z","pushed_at":"2017-02-06T16:38:25Z","git_url":"git://github.com/pingcap/tikv.git","ssh_url":"git@github.com:pingcap/tikv.git","clone_url":"https://github.com/pingcap/tikv.git","svn_url":"https://github.com/pingcap/tikv","homepage":"","size":6632,"stargazers_count":1495,"watchers_count":1495,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":137,"mirror_url":null,"open_issues_count":111,"forks":137,"open_issues":111,"watchers":1495,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"f92a8167706441c193d8adda9b72f2d8ac657e56","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":48833910,"name":"tikv","full_name":"pingcap/tikv","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":false,"url":"https://api.github.com/repos/pingcap/tikv","forks_url":"https://api.github.com/repos/pingcap/tikv/forks","keys_url":"https://api.github.com/repos/pingcap/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tikv/teams","hooks_url":"https://api.github.com/repos/pingcap/tikv/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tikv/events","assignees_url":"https://api.github.com/repos/pingcap/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tikv/tags","blobs_url":"https://api.github.com/repos/pingcap/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tikv/languages","stargazers_url":"https://api.github.com/repos/pingcap/tikv/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tikv/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tikv/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tikv/subscription","commits_url":"https://api.github.com/repos/pingcap/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tikv/merges","archive_url":"https://api.github.com/repos/pingcap/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tikv/downloads","issues_url":"https://api.github.com/repos/pingcap/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tikv/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tikv/deployments","created_at":"2015-12-31T04:51:32Z","updated_at":"2017-02-06T13:33:19Z","pushed_at":"2017-02-06T16:38:25Z","git_url":"git://github.com/pingcap/tikv.git","ssh_url":"git@github.com:pingcap/tikv.git","clone_url":"https://github.com/pingcap/tikv.git","svn_url":"https://github.com/pingcap/tikv","homepage":"","size":6632,"stargazers_count":1495,"watchers_count":1495,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":137,"mirror_url":null,"open_issues_count":111,"forks":137,"open_issues":111,"watchers":1495,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1578"},"html":{"href":"https://github.com/pingcap/tikv/pull/1578"},"issue":{"href":"https://api.github.com/repos/pingcap/tikv/issues/1578"},"comments":{"href":"https://api.github.com/repos/pingcap/tikv/issues/1578/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1578/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1578/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tikv/statuses/8b8e57e9f5e5d3b70d2b30774042738b076521c0"}}}}
{"actor":{"display_login":"siddontang"}}