{"action":"created","comment":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/comments/24239021","id":24239021,"diff_hunk":"@@ -16,36 +16,54 @@\n  * specific language governing permissions and limitations\n  * under the License.\n  */\n-package org.elasticsearch.search.aggregations;\n \n-import com.google.common.base.Predicate;\n-import com.google.common.collect.Iterables;\n+package org.elasticsearch.search.aggregations;\n \n-import org.apache.lucene.index.LeafReaderContext;\n-import org.apache.lucene.search.Scorer;\n import org.elasticsearch.ElasticsearchParseException;\n import org.elasticsearch.common.ParseField;\n import org.elasticsearch.common.lease.Releasable;\n-import org.elasticsearch.common.util.BigArrays;\n import org.elasticsearch.common.xcontent.XContentParser;\n import org.elasticsearch.search.aggregations.bucket.BucketsAggregator;\n-import org.elasticsearch.search.aggregations.bucket.DeferringBucketCollector;\n import org.elasticsearch.search.aggregations.support.AggregationContext;\n import org.elasticsearch.search.internal.SearchContext;\n-import org.elasticsearch.search.internal.SearchContext.Lifetime;\n-import org.elasticsearch.search.query.QueryPhaseExecutionException;\n \n import java.io.IOException;\n-import java.util.ArrayList;\n-import java.util.Arrays;\n import java.util.EnumSet;\n-import java.util.HashMap;\n-import java.util.List;\n-import java.util.Map;\n \n+/**\n+ * An Aggregator.\n+ */\n+// IMPORTANT: DO NOT add methods to this class unless strictly required.\n+// On the other hand, if you can remove methods from it, you are highly welcome!\n public abstract class Aggregator extends BucketCollector implements Releasable {","path":"src/main/java/org/elasticsearch/search/aggregations/Aggregator.java","position":37,"original_position":37,"commit_id":"0652cfd9a5f2d41dd4bafeed27683c4b9038805f","original_commit_id":"0652cfd9a5f2d41dd4bafeed27683c4b9038805f","user":{"login":"colings86","id":236731,"avatar_url":"https://avatars.githubusercontent.com/u/236731?v=3","gravatar_id":"","url":"https://api.github.com/users/colings86","html_url":"https://github.com/colings86","followers_url":"https://api.github.com/users/colings86/followers","following_url":"https://api.github.com/users/colings86/following{/other_user}","gists_url":"https://api.github.com/users/colings86/gists{/gist_id}","starred_url":"https://api.github.com/users/colings86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colings86/subscriptions","organizations_url":"https://api.github.com/users/colings86/orgs","repos_url":"https://api.github.com/users/colings86/repos","events_url":"https://api.github.com/users/colings86/events{/privacy}","received_events_url":"https://api.github.com/users/colings86/received_events","type":"User","site_admin":false},"body":"With the exception of the `descendsFromBucketAggregator` method, which could probably be moved to AggregatorBase as it's an implementation detail and not integral to the idea of an Aggregator, all the methods in this class are abstract. Should we make Aggregator an interface?","created_at":"2015-02-06T13:07:35Z","updated_at":"2015-02-06T13:07:35Z","html_url":"https://github.com/elasticsearch/elasticsearch/pull/9544#discussion_r24239021","pull_request_url":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/9544","_links":{"self":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/comments/24239021"},"html":{"href":"https://github.com/elasticsearch/elasticsearch/pull/9544#discussion_r24239021"},"pull_request":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/9544"}}},"pull_request":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/9544","id":28540946,"html_url":"https://github.com/elasticsearch/elasticsearch/pull/9544","diff_url":"https://github.com/elasticsearch/elasticsearch/pull/9544.diff","patch_url":"https://github.com/elasticsearch/elasticsearch/pull/9544.patch","issue_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/9544","number":9544,"state":"open","locked":false,"title":"Aggs: Refactor aggregations to use lucene5-style collectors.","user":{"login":"jpountz","id":299848,"avatar_url":"https://avatars.githubusercontent.com/u/299848?v=3","gravatar_id":"","url":"https://api.github.com/users/jpountz","html_url":"https://github.com/jpountz","followers_url":"https://api.github.com/users/jpountz/followers","following_url":"https://api.github.com/users/jpountz/following{/other_user}","gists_url":"https://api.github.com/users/jpountz/gists{/gist_id}","starred_url":"https://api.github.com/users/jpountz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpountz/subscriptions","organizations_url":"https://api.github.com/users/jpountz/orgs","repos_url":"https://api.github.com/users/jpountz/repos","events_url":"https://api.github.com/users/jpountz/events{/privacy}","received_events_url":"https://api.github.com/users/jpountz/received_events","type":"User","site_admin":false},"body":"Aggregators now return a new collector instance per segment, like Lucene 5 does\r\nwith its oal.search.Collector API. This is important for us because things like\r\nknowing whether the field is single or multi-valued is only known at a segment\r\nlevel.\r\n\r\nIn order to do that I had to change aggregators to notify their sub aggregators\r\nof new incoming segments (pretty much in the spirit of #6477) while everything\r\nused to be centralized in the AggregationContext class. While this might slow\r\ndown a bit deeply nested aggregation trees, this also makes the children\r\naggregation and the `breadth_first` collection mode much better options since\r\nthey can now only replay what they need while they used to have to replay the\r\nwhole aggregation tree.\r\n\r\nI also took advantage of this big refactoring to remove some abstractions that\r\nwere not really required like ValuesSource.MetaData or BucketAnalysisCollector.\r\nI also splitted Aggregator into Aggregator and AggregatorBase in order to\r\nseparate the Aggregator API from implementation helpers.","created_at":"2015-02-03T10:24:27Z","updated_at":"2015-02-06T13:07:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"718465dadca770a92eb5d752891ef415dc439479","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/9544/commits","review_comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/9544/comments","review_comment_url":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/comments/{number}","comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/9544/comments","statuses_url":"https://api.github.com/repos/elasticsearch/elasticsearch/statuses/0652cfd9a5f2d41dd4bafeed27683c4b9038805f","head":{"label":"jpountz:enhancement/aggs_lucene5","ref":"enhancement/aggs_lucene5","sha":"0652cfd9a5f2d41dd4bafeed27683c4b9038805f","user":{"login":"jpountz","id":299848,"avatar_url":"https://avatars.githubusercontent.com/u/299848?v=3","gravatar_id":"","url":"https://api.github.com/users/jpountz","html_url":"https://github.com/jpountz","followers_url":"https://api.github.com/users/jpountz/followers","following_url":"https://api.github.com/users/jpountz/following{/other_user}","gists_url":"https://api.github.com/users/jpountz/gists{/gist_id}","starred_url":"https://api.github.com/users/jpountz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpountz/subscriptions","organizations_url":"https://api.github.com/users/jpountz/orgs","repos_url":"https://api.github.com/users/jpountz/repos","events_url":"https://api.github.com/users/jpountz/events{/privacy}","received_events_url":"https://api.github.com/users/jpountz/received_events","type":"User","site_admin":false},"repo":{"id":9633891,"name":"elasticsearch","full_name":"jpountz/elasticsearch","owner":{"login":"jpountz","id":299848,"avatar_url":"https://avatars.githubusercontent.com/u/299848?v=3","gravatar_id":"","url":"https://api.github.com/users/jpountz","html_url":"https://github.com/jpountz","followers_url":"https://api.github.com/users/jpountz/followers","following_url":"https://api.github.com/users/jpountz/following{/other_user}","gists_url":"https://api.github.com/users/jpountz/gists{/gist_id}","starred_url":"https://api.github.com/users/jpountz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpountz/subscriptions","organizations_url":"https://api.github.com/users/jpountz/orgs","repos_url":"https://api.github.com/users/jpountz/repos","events_url":"https://api.github.com/users/jpountz/events{/privacy}","received_events_url":"https://api.github.com/users/jpountz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jpountz/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/jpountz/elasticsearch","forks_url":"https://api.github.com/repos/jpountz/elasticsearch/forks","keys_url":"https://api.github.com/repos/jpountz/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jpountz/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jpountz/elasticsearch/teams","hooks_url":"https://api.github.com/repos/jpountz/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/jpountz/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/jpountz/elasticsearch/events","assignees_url":"https://api.github.com/repos/jpountz/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/jpountz/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/jpountz/elasticsearch/tags","blobs_url":"https://api.github.com/repos/jpountz/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jpountz/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jpountz/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/jpountz/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jpountz/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/jpountz/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/jpountz/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/jpountz/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/jpountz/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/jpountz/elasticsearch/subscription","commits_url":"https://api.github.com/repos/jpountz/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/jpountz/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/jpountz/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/jpountz/elasticsearch/issues/comments/{number}","contents_url":"https://api.github.com/repos/jpountz/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/jpountz/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jpountz/elasticsearch/merges","archive_url":"https://api.github.com/repos/jpountz/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jpountz/elasticsearch/downloads","issues_url":"https://api.github.com/repos/jpountz/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/jpountz/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/jpountz/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/jpountz/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jpountz/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/jpountz/elasticsearch/releases{/id}","created_at":"2013-04-23T21:37:49Z","updated_at":"2014-11-05T08:22:11Z","pushed_at":"2015-02-05T14:18:17Z","git_url":"git://github.com/jpountz/elasticsearch.git","ssh_url":"git@github.com:jpountz/elasticsearch.git","clone_url":"https://github.com/jpountz/elasticsearch.git","svn_url":"https://github.com/jpountz/elasticsearch","homepage":"http://elasticsearch.org","size":79721,"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":"elasticsearch:master","ref":"master","sha":"74c7b5a197b1a0df3dceef7aad9610bfb9046c1f","user":{"login":"elasticsearch","id":141304,"avatar_url":"https://avatars.githubusercontent.com/u/141304?v=3","gravatar_id":"","url":"https://api.github.com/users/elasticsearch","html_url":"https://github.com/elasticsearch","followers_url":"https://api.github.com/users/elasticsearch/followers","following_url":"https://api.github.com/users/elasticsearch/following{/other_user}","gists_url":"https://api.github.com/users/elasticsearch/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticsearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticsearch/subscriptions","organizations_url":"https://api.github.com/users/elasticsearch/orgs","repos_url":"https://api.github.com/users/elasticsearch/repos","events_url":"https://api.github.com/users/elasticsearch/events{/privacy}","received_events_url":"https://api.github.com/users/elasticsearch/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elasticsearch/elasticsearch","owner":{"login":"elasticsearch","id":141304,"avatar_url":"https://avatars.githubusercontent.com/u/141304?v=3","gravatar_id":"","url":"https://api.github.com/users/elasticsearch","html_url":"https://github.com/elasticsearch","followers_url":"https://api.github.com/users/elasticsearch/followers","following_url":"https://api.github.com/users/elasticsearch/following{/other_user}","gists_url":"https://api.github.com/users/elasticsearch/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticsearch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticsearch/subscriptions","organizations_url":"https://api.github.com/users/elasticsearch/orgs","repos_url":"https://api.github.com/users/elasticsearch/repos","events_url":"https://api.github.com/users/elasticsearch/events{/privacy}","received_events_url":"https://api.github.com/users/elasticsearch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elasticsearch/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elasticsearch/elasticsearch","forks_url":"https://api.github.com/repos/elasticsearch/elasticsearch/forks","keys_url":"https://api.github.com/repos/elasticsearch/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elasticsearch/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elasticsearch/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elasticsearch/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elasticsearch/elasticsearch/events","assignees_url":"https://api.github.com/repos/elasticsearch/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elasticsearch/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elasticsearch/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elasticsearch/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elasticsearch/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elasticsearch/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elasticsearch/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elasticsearch/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elasticsearch/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elasticsearch/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elasticsearch/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elasticsearch/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elasticsearch/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elasticsearch/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elasticsearch/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/comments/{number}","contents_url":"https://api.github.com/repos/elasticsearch/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elasticsearch/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elasticsearch/elasticsearch/merges","archive_url":"https://api.github.com/repos/elasticsearch/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elasticsearch/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elasticsearch/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elasticsearch/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elasticsearch/elasticsearch/releases{/id}","created_at":"2010-02-08T13:20:56Z","updated_at":"2015-02-06T11:57:41Z","pushed_at":"2015-02-06T11:57:41Z","git_url":"git://github.com/elasticsearch/elasticsearch.git","ssh_url":"git@github.com:elasticsearch/elasticsearch.git","clone_url":"https://github.com/elasticsearch/elasticsearch.git","svn_url":"https://github.com/elasticsearch/elasticsearch","homepage":"http://elasticsearch.org","size":267872,"stargazers_count":9869,"watchers_count":9869,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3030,"mirror_url":null,"open_issues_count":938,"forks":3030,"open_issues":938,"watchers":9869,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/9544"},"html":{"href":"https://github.com/elasticsearch/elasticsearch/pull/9544"},"issue":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/9544"},"comments":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/9544/comments"},"review_comments":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/9544/comments"},"review_comment":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch/pulls/9544/commits"},"statuses":{"href":"https://api.github.com/repos/elasticsearch/elasticsearch/statuses/0652cfd9a5f2d41dd4bafeed27683c4b9038805f"}}}}