{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/54237586","id":54237586,"diff_hunk":"@@ -0,0 +1,224 @@\n+/*\n+ * Licensed to Elasticsearch under one or more contributor\n+ * license agreements. See the NOTICE file distributed with\n+ * this work for additional information regarding copyright\n+ * ownership. Elasticsearch licenses this file to you under\n+ * the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.elasticsearch.action.search;\n+\n+import com.carrotsearch.hppc.IntArrayList;\n+import org.apache.lucene.search.ScoreDoc;\n+import org.elasticsearch.action.ActionListener;\n+import org.elasticsearch.action.ActionRunnable;\n+import org.elasticsearch.cluster.ClusterService;\n+import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;\n+import org.elasticsearch.cluster.node.DiscoveryNode;\n+import org.elasticsearch.common.logging.ESLogger;\n+import org.elasticsearch.common.util.concurrent.AtomicArray;\n+import org.elasticsearch.search.SearchShardTarget;\n+import org.elasticsearch.search.action.SearchServiceTransportAction;\n+import org.elasticsearch.search.controller.SearchPhaseController;\n+import org.elasticsearch.search.dfs.AggregatedDfs;\n+import org.elasticsearch.search.dfs.DfsSearchResult;\n+import org.elasticsearch.search.fetch.FetchSearchResult;\n+import org.elasticsearch.search.fetch.ShardFetchSearchRequest;\n+import org.elasticsearch.search.internal.InternalSearchResponse;\n+import org.elasticsearch.search.internal.ShardSearchTransportRequest;\n+import org.elasticsearch.search.query.QuerySearchRequest;\n+import org.elasticsearch.search.query.QuerySearchResult;\n+import org.elasticsearch.threadpool.ThreadPool;\n+\n+import java.io.IOException;\n+import java.util.concurrent.atomic.AtomicInteger;\n+\n+class SearchDfsQueryThenFetchAsyncAction extends AbstractSearchAsyncAction<DfsSearchResult> {\n+\n+    final AtomicArray<QuerySearchResult> queryResults;\n+    final AtomicArray<FetchSearchResult> fetchResults;\n+    final AtomicArray<IntArrayList> docIdsToLoad;\n+\n+    SearchDfsQueryThenFetchAsyncAction(ESLogger logger, SearchServiceTransportAction searchService,\n+                                               ClusterService clusterService, IndexNameExpressionResolver indexNameExpressionResolver,\n+                                               SearchPhaseController searchPhaseController, ThreadPool threadPool,\n+                                               SearchRequest request, ActionListener<SearchResponse> listener) {\n+        super(logger, searchService, clusterService, indexNameExpressionResolver, searchPhaseController, threadPool, request, listener);\n+        queryResults = new AtomicArray<>(firstResults.length());\n+        fetchResults = new AtomicArray<>(firstResults.length());\n+        docIdsToLoad = new AtomicArray<>(firstResults.length());\n+    }\n+\n+    @Override\n+    protected String firstPhaseName() {\n+        return \"dfs\";\n+    }\n+\n+    @Override\n+    protected void sendExecuteFirstPhase(DiscoveryNode node, ShardSearchTransportRequest request,\n+                                         ActionListener<DfsSearchResult> listener) {\n+        searchService.sendExecuteDfs(node, request, listener);\n+    }\n+\n+    @Override\n+    protected void moveToSecondPhase() {\n+        final AggregatedDfs dfs = searchPhaseController.aggregateDfs(firstResults);\n+        final AtomicInteger counter = new AtomicInteger(firstResults.asList().size());\n+        for (final AtomicArray.Entry<DfsSearchResult> entry : firstResults.asList()) {\n+            DfsSearchResult dfsResult = entry.value;\n+            DiscoveryNode node = nodes.get(dfsResult.shardTarget().nodeId());\n+            QuerySearchRequest querySearchRequest = new QuerySearchRequest(request, dfsResult.id(), dfs);\n+            executeQuery(entry.index, dfsResult, counter, querySearchRequest, node);\n+        }\n+    }\n+\n+    void executeQuery(final int shardIndex, final DfsSearchResult dfsResult, final AtomicInteger counter,\n+                      final QuerySearchRequest querySearchRequest, final DiscoveryNode node) {\n+                            searchService.sendExecuteQuery(node, querySearchRequest, new ActionListener<QuerySearchResult>() {","path":"core/src/main/java/org/elasticsearch/action/search/SearchDfsQueryThenFetchAsyncAction.java","position":88,"original_position":88,"commit_id":"aea31face5cbe13dddf911085a06f845bec29848","original_commit_id":"aea31face5cbe13dddf911085a06f845bec29848","user":{"login":"jaymode","id":4339958,"avatar_url":"https://avatars.githubusercontent.com/u/4339958?v=3","gravatar_id":"","url":"https://api.github.com/users/jaymode","html_url":"https://github.com/jaymode","followers_url":"https://api.github.com/users/jaymode/followers","following_url":"https://api.github.com/users/jaymode/following{/other_user}","gists_url":"https://api.github.com/users/jaymode/gists{/gist_id}","starred_url":"https://api.github.com/users/jaymode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaymode/subscriptions","organizations_url":"https://api.github.com/users/jaymode/orgs","repos_url":"https://api.github.com/users/jaymode/repos","events_url":"https://api.github.com/users/jaymode/events{/privacy}","received_events_url":"https://api.github.com/users/jaymode/received_events","type":"User","site_admin":false},"body":"indentation looks off here","created_at":"2016-02-26T12:35:46Z","updated_at":"2016-02-26T12:35:46Z","html_url":"https://github.com/elastic/elasticsearch/pull/16758#discussion_r54237586","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/16758","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/54237586"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/16758#discussion_r54237586"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/16758"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/16758","id":60128498,"html_url":"https://github.com/elastic/elasticsearch/pull/16758","diff_url":"https://github.com/elastic/elasticsearch/pull/16758.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/16758.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16758","number":16758,"state":"open","locked":false,"title":"Cleanup search sub transport actions and collapse o.e.action.search.type package into o.e.action.search","user":{"login":"javanna","id":832460,"avatar_url":"https://avatars.githubusercontent.com/u/832460?v=3","gravatar_id":"","url":"https://api.github.com/users/javanna","html_url":"https://github.com/javanna","followers_url":"https://api.github.com/users/javanna/followers","following_url":"https://api.github.com/users/javanna/following{/other_user}","gists_url":"https://api.github.com/users/javanna/gists{/gist_id}","starred_url":"https://api.github.com/users/javanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javanna/subscriptions","organizations_url":"https://api.github.com/users/javanna/orgs","repos_url":"https://api.github.com/users/javanna/repos","events_url":"https://api.github.com/users/javanna/events{/privacy}","received_events_url":"https://api.github.com/users/javanna/received_events","type":"User","site_admin":false},"body":"TransportSearchTypeAction and subclasses are not actually transport actions, but just support classes useful for their inner async actions that can easily be extracted out so that we get rid of one too many level of abstraction.\r\n\r\nSame pattern can be applied to TransportSearchScrollQueryAndFetchAction & TransportSearchScrollQueryThenFetchAction which we could remove in favour of keeping only their inner classes named SearchScrollQueryAndFetchAsyncAction and SearchScrollQueryThenFetchAsyncAction.\r\n\r\nRemove org.elasticsearch.action.search.type package, collapsed remaining classes into existing org.elasticsearch.action.search package\r\n\r\nMake also ParsedScrollId ScrollIdForNode and TransportSearchHelper classes and their methods package private.\r\n\r\nCloses #11710","created_at":"2016-02-22T05:56:55Z","updated_at":"2016-02-26T12:35:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b92dfcb5accd85e4356982c152ee48ef627f2c86","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/16758/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/16758/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/16758/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/aea31face5cbe13dddf911085a06f845bec29848","head":{"label":"javanna:enhancement/remove_action_search_type_package","ref":"enhancement/remove_action_search_type_package","sha":"aea31face5cbe13dddf911085a06f845bec29848","user":{"login":"javanna","id":832460,"avatar_url":"https://avatars.githubusercontent.com/u/832460?v=3","gravatar_id":"","url":"https://api.github.com/users/javanna","html_url":"https://github.com/javanna","followers_url":"https://api.github.com/users/javanna/followers","following_url":"https://api.github.com/users/javanna/following{/other_user}","gists_url":"https://api.github.com/users/javanna/gists{/gist_id}","starred_url":"https://api.github.com/users/javanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javanna/subscriptions","organizations_url":"https://api.github.com/users/javanna/orgs","repos_url":"https://api.github.com/users/javanna/repos","events_url":"https://api.github.com/users/javanna/events{/privacy}","received_events_url":"https://api.github.com/users/javanna/received_events","type":"User","site_admin":false},"repo":{"id":6652220,"name":"elasticsearch","full_name":"javanna/elasticsearch","owner":{"login":"javanna","id":832460,"avatar_url":"https://avatars.githubusercontent.com/u/832460?v=3","gravatar_id":"","url":"https://api.github.com/users/javanna","html_url":"https://github.com/javanna","followers_url":"https://api.github.com/users/javanna/followers","following_url":"https://api.github.com/users/javanna/following{/other_user}","gists_url":"https://api.github.com/users/javanna/gists{/gist_id}","starred_url":"https://api.github.com/users/javanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javanna/subscriptions","organizations_url":"https://api.github.com/users/javanna/orgs","repos_url":"https://api.github.com/users/javanna/repos","events_url":"https://api.github.com/users/javanna/events{/privacy}","received_events_url":"https://api.github.com/users/javanna/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/javanna/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/javanna/elasticsearch","forks_url":"https://api.github.com/repos/javanna/elasticsearch/forks","keys_url":"https://api.github.com/repos/javanna/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javanna/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javanna/elasticsearch/teams","hooks_url":"https://api.github.com/repos/javanna/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/javanna/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/javanna/elasticsearch/events","assignees_url":"https://api.github.com/repos/javanna/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/javanna/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/javanna/elasticsearch/tags","blobs_url":"https://api.github.com/repos/javanna/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javanna/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javanna/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/javanna/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javanna/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/javanna/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/javanna/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/javanna/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/javanna/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/javanna/elasticsearch/subscription","commits_url":"https://api.github.com/repos/javanna/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/javanna/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/javanna/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/javanna/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/javanna/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/javanna/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javanna/elasticsearch/merges","archive_url":"https://api.github.com/repos/javanna/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javanna/elasticsearch/downloads","issues_url":"https://api.github.com/repos/javanna/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/javanna/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/javanna/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/javanna/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javanna/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/javanna/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/javanna/elasticsearch/deployments","created_at":"2012-11-12T11:11:09Z","updated_at":"2015-04-30T08:59:29Z","pushed_at":"2016-02-25T15:50:10Z","git_url":"git://github.com/javanna/elasticsearch.git","ssh_url":"git@github.com:javanna/elasticsearch.git","clone_url":"https://github.com/javanna/elasticsearch.git","svn_url":"https://github.com/javanna/elasticsearch","homepage":"http://elasticsearch.org","size":193084,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"fa885f2e9608e07c2209ab3203533f04e9b5a4ae","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/elasticsearch/deployments","created_at":"2010-02-08T13:20:56Z","updated_at":"2016-02-26T11:14:05Z","pushed_at":"2016-02-26T12:13:53Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":293888,"stargazers_count":15791,"watchers_count":15791,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5057,"mirror_url":null,"open_issues_count":1166,"forks":5057,"open_issues":1166,"watchers":15791,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/16758"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/16758"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/16758"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/16758/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/16758/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/16758/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/aea31face5cbe13dddf911085a06f845bec29848"}}}}