{"action":"created","comment":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/67760553","id":67760553,"diff_hunk":"@@ -131,49 +131,56 @@ OrderByExecutor::p_execute(const NValueArray &params)\n     VOLT_TRACE(\"Input Table:\\n '%s'\", input_table->debug().c_str());\n     TableIterator iterator = input_table->iterator();\n     TableTuple tuple(input_table->schema());\n-    vector<TableTuple> xs;\n-    ProgressMonitorProxy pmp(m_engine, this);\n-    while (iterator.next(tuple))\n-    {\n-        pmp.countdownProgress();\n-        assert(tuple.isActive());\n-        xs.push_back(tuple);\n-    }\n-    VOLT_TRACE(\"\\n***** Input Table PreSort:\\n '%s'\",\n-               input_table->debug().c_str());\n \n+    // If limit == 0 we have no work here.  There's no need to sort anything,\n+    // or to fetch the vector of tuples from the input.  If limit < 0 we\n+    // need to do the loop below, though.  The only case where we can skip\n+    // is if limit == 0.\n+    if (limit != 0) {\n+        vector<TableTuple> xs;\n+        ProgressMonitorProxy pmp(m_engine, this);\n+        while (iterator.next(tuple))\n+        {\n+            pmp.countdownProgress();\n+            assert(tuple.isActive());\n+            xs.push_back(tuple);\n+        }\n+        VOLT_TRACE(\"\\n***** Input Table PreSort:\\n '%s'\",\n+                   input_table->debug().c_str());\n \n-    if (limit >= 0 && xs.begin() + limit + offset < xs.end()) {\n-        // partial sort\n-        partial_sort(xs.begin(), xs.begin() + limit + offset, xs.end(),\n-                AbstractExecutor::TupleComparer(node->getSortExpressions(), node->getSortDirections()));\n-    } else {\n-        // full sort\n-        sort(xs.begin(), xs.end(),\n-                AbstractExecutor::TupleComparer(node->getSortExpressions(), node->getSortDirections()));\n-    }\n \n-    int tuple_ctr = 0;\n-    int tuple_skipped = 0;\n-    for (vector<TableTuple>::iterator it = xs.begin(); it != xs.end(); it++)\n-    {\n-        //\n-        // Check if has gone past the offset\n-        //\n-        if (tuple_skipped < offset) {\n-            tuple_skipped++;\n-            continue;\n+        if (limit >= 0 && xs.begin() + limit + offset < xs.end()) {","path":"src/ee/executors/orderbyexecutor.cpp","position":51,"original_position":51,"commit_id":"938688d5573163011a808dfa51c9c4dceb11e79e","original_commit_id":"938688d5573163011a808dfa51c9c4dceb11e79e","user":{"login":"yzhang1991","id":6643318,"avatar_url":"https://avatars.githubusercontent.com/u/6643318?v=3","gravatar_id":"","url":"https://api.github.com/users/yzhang1991","html_url":"https://github.com/yzhang1991","followers_url":"https://api.github.com/users/yzhang1991/followers","following_url":"https://api.github.com/users/yzhang1991/following{/other_user}","gists_url":"https://api.github.com/users/yzhang1991/gists{/gist_id}","starred_url":"https://api.github.com/users/yzhang1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yzhang1991/subscriptions","organizations_url":"https://api.github.com/users/yzhang1991/orgs","repos_url":"https://api.github.com/users/yzhang1991/repos","events_url":"https://api.github.com/users/yzhang1991/events{/privacy}","received_events_url":"https://api.github.com/users/yzhang1991/received_events","type":"User","site_admin":false},"body":"Now, remove `limit >= 0` here because this code is only reachable if `limit > 0`.","created_at":"2016-06-20T20:31:11Z","updated_at":"2016-06-20T20:31:11Z","html_url":"https://github.com/VoltDB/voltdb/pull/3708#discussion_r67760553","pull_request_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3708","_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/67760553"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/3708#discussion_r67760553"},"pull_request":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3708"}}},"pull_request":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3708","id":74472118,"html_url":"https://github.com/VoltDB/voltdb/pull/3708","diff_url":"https://github.com/VoltDB/voltdb/pull/3708.diff","patch_url":"https://github.com/VoltDB/voltdb/pull/3708.patch","issue_url":"https://api.github.com/repos/VoltDB/voltdb/issues/3708","number":3708,"state":"open","locked":false,"title":"Limit 0 should really return 0 rows.","user":{"login":"BillWhite","id":924098,"avatar_url":"https://avatars.githubusercontent.com/u/924098?v=3","gravatar_id":"","url":"https://api.github.com/users/BillWhite","html_url":"https://github.com/BillWhite","followers_url":"https://api.github.com/users/BillWhite/followers","following_url":"https://api.github.com/users/BillWhite/following{/other_user}","gists_url":"https://api.github.com/users/BillWhite/gists{/gist_id}","starred_url":"https://api.github.com/users/BillWhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillWhite/subscriptions","organizations_url":"https://api.github.com/users/BillWhite/orgs","repos_url":"https://api.github.com/users/BillWhite/repos","events_url":"https://api.github.com/users/BillWhite/events{/privacy}","received_events_url":"https://api.github.com/users/BillWhite/received_events","type":"User","site_admin":false},"body":"The algorithm in the order by executor for limit nodes was incorrect.\r\nThis commit makes limit 0 do almost no work.  It was reading the input\r\ntable and sorting it.  The sort was a special case which only does a\r\npartial sort, but copying the input table into a std::vector is\r\nunnecessary and can't be zero cost.\r\n\r\nhttps://issues.voltdb.com/browse/ENG-10559\r\n","created_at":"2016-06-20T16:26:06Z","updated_at":"2016-06-20T20:31:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d60cab35de801c8aaf6c34845c323af07652fc2f","assignee":{"login":"yzhang1991","id":6643318,"avatar_url":"https://avatars.githubusercontent.com/u/6643318?v=3","gravatar_id":"","url":"https://api.github.com/users/yzhang1991","html_url":"https://github.com/yzhang1991","followers_url":"https://api.github.com/users/yzhang1991/followers","following_url":"https://api.github.com/users/yzhang1991/following{/other_user}","gists_url":"https://api.github.com/users/yzhang1991/gists{/gist_id}","starred_url":"https://api.github.com/users/yzhang1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yzhang1991/subscriptions","organizations_url":"https://api.github.com/users/yzhang1991/orgs","repos_url":"https://api.github.com/users/yzhang1991/repos","events_url":"https://api.github.com/users/yzhang1991/events{/privacy}","received_events_url":"https://api.github.com/users/yzhang1991/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3708/commits","review_comments_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3708/comments","review_comment_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/issues/3708/comments","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/938688d5573163011a808dfa51c9c4dceb11e79e","head":{"label":"VoltDB:ENG-10559-LimitZeroOrderBy","ref":"ENG-10559-LimitZeroOrderBy","sha":"938688d5573163011a808dfa51c9c4dceb11e79e","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","deployments_url":"https://api.github.com/repos/VoltDB/voltdb/deployments","created_at":"2011-09-23T18:46:12Z","updated_at":"2016-06-20T10:04:10Z","pushed_at":"2016-06-20T20:09:28Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":593208,"stargazers_count":788,"watchers_count":788,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":245,"mirror_url":null,"open_issues_count":40,"forks":245,"open_issues":40,"watchers":788,"default_branch":"master"}},"base":{"label":"VoltDB:master","ref":"master","sha":"70d254c035af1707ffea3d2f4b87cabde3a2d49d","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","deployments_url":"https://api.github.com/repos/VoltDB/voltdb/deployments","created_at":"2011-09-23T18:46:12Z","updated_at":"2016-06-20T10:04:10Z","pushed_at":"2016-06-20T20:09:28Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":593208,"stargazers_count":788,"watchers_count":788,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":245,"mirror_url":null,"open_issues_count":40,"forks":245,"open_issues":40,"watchers":788,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3708"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/3708"},"issue":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/3708"},"comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/3708/comments"},"review_comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3708/comments"},"review_comment":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3708/commits"},"statuses":{"href":"https://api.github.com/repos/VoltDB/voltdb/statuses/938688d5573163011a808dfa51c9c4dceb11e79e"}}}}
{"actor":{"display_login":"yzhang1991"}}