{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/227551947","pull_request_review_id":167615647,"id":227551947,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzU1MTk0Nw==","diff_hunk":"@@ -0,0 +1,147 @@\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.search.aggregations.metrics;\n+\n+import org.apache.lucene.index.LeafReaderContext;\n+import org.apache.lucene.search.ScoreMode;\n+import org.elasticsearch.common.Nullable;\n+import org.elasticsearch.common.lease.Releasables;\n+import org.elasticsearch.common.util.BigArrays;\n+import org.elasticsearch.common.util.ObjectArray;\n+import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;\n+import org.elasticsearch.search.DocValueFormat;\n+import org.elasticsearch.search.aggregations.Aggregator;\n+import org.elasticsearch.search.aggregations.InternalAggregation;\n+import org.elasticsearch.search.aggregations.LeafBucketCollector;\n+import org.elasticsearch.search.aggregations.LeafBucketCollectorBase;\n+import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;\n+import org.elasticsearch.search.aggregations.support.ValuesSource;\n+import org.elasticsearch.search.internal.SearchContext;\n+\n+import java.io.IOException;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Objects;\n+\n+import static org.elasticsearch.search.aggregations.metrics.InternalMedianAbsoluteDeviation.computeMedianAbsoluteDeviation;\n+\n+public class MedianAbsoluteDeviationAggregator extends NumericMetricsAggregator.SingleValue {\n+\n+    private final ValuesSource.Numeric valuesSource;\n+    private final DocValueFormat format;\n+\n+    private final double compression;\n+\n+    private ObjectArray<TDigestState> valueSketches;\n+\n+    public MedianAbsoluteDeviationAggregator(String name,\n+                                             SearchContext context,\n+                                             Aggregator parent,\n+                                             List<PipelineAggregator> pipelineAggregators,\n+                                             Map<String, Object> metaData,\n+                                             @Nullable ValuesSource.Numeric valuesSource,\n+                                             DocValueFormat format,\n+                                             double compression) throws IOException {\n+\n+        super(name, context, parent, pipelineAggregators, metaData);\n+\n+        this.valuesSource = valuesSource;\n+        this.format = Objects.requireNonNull(format);\n+\n+        this.compression = compression;\n+","path":"server/src/main/java/org/elasticsearch/search/aggregations/metrics/MedianAbsoluteDeviationAggregator.java","position":69,"original_position":69,"commit_id":"22deb4596c777d8f95a3b09c533534751bb6001f","original_commit_id":"22deb4596c777d8f95a3b09c533534751bb6001f","user":{"login":"polyfractal","id":1224228,"node_id":"MDQ6VXNlcjEyMjQyMjg=","avatar_url":"https://avatars1.githubusercontent.com/u/1224228?v=4","gravatar_id":"","url":"https://api.github.com/users/polyfractal","html_url":"https://github.com/polyfractal","followers_url":"https://api.github.com/users/polyfractal/followers","following_url":"https://api.github.com/users/polyfractal/following{/other_user}","gists_url":"https://api.github.com/users/polyfractal/gists{/gist_id}","starred_url":"https://api.github.com/users/polyfractal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polyfractal/subscriptions","organizations_url":"https://api.github.com/users/polyfractal/orgs","repos_url":"https://api.github.com/users/polyfractal/repos","events_url":"https://api.github.com/users/polyfractal/events{/privacy}","received_events_url":"https://api.github.com/users/polyfractal/received_events","type":"User","site_admin":false},"body":"Please don't hate me nit: whitespace around these assignments :)","created_at":"2018-10-23T20:29:37Z","updated_at":"2018-10-23T20:51:32Z","html_url":"https://github.com/elastic/elasticsearch/pull/34482#discussion_r227551947","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/34482","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/227551947"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/34482#discussion_r227551947"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/34482"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/34482","id":223006945,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzMDA2OTQ1","html_url":"https://github.com/elastic/elasticsearch/pull/34482","diff_url":"https://github.com/elastic/elasticsearch/pull/34482.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/34482.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/34482","number":34482,"state":"open","locked":false,"title":"median absolute deviation agg","user":{"login":"andyb-elastic","id":29205940,"node_id":"MDQ6VXNlcjI5MjA1OTQw","avatar_url":"https://avatars2.githubusercontent.com/u/29205940?v=4","gravatar_id":"","url":"https://api.github.com/users/andyb-elastic","html_url":"https://github.com/andyb-elastic","followers_url":"https://api.github.com/users/andyb-elastic/followers","following_url":"https://api.github.com/users/andyb-elastic/following{/other_user}","gists_url":"https://api.github.com/users/andyb-elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/andyb-elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyb-elastic/subscriptions","organizations_url":"https://api.github.com/users/andyb-elastic/orgs","repos_url":"https://api.github.com/users/andyb-elastic/repos","events_url":"https://api.github.com/users/andyb-elastic/events{/privacy}","received_events_url":"https://api.github.com/users/andyb-elastic/received_events","type":"User","site_admin":false},"body":"This commit adds a new single value metric aggregation that calculates\r\nthe statistic called median absolute deviation, which is a measure of\r\nvariability that works on more types of data than standard deviation\r\n\r\nOur calculation of MAD is approximated using t-digests. In the collect\r\nphase, we collect each value visited into a t-digest. In the reduce\r\nphase, we merge all value t-digests, then create a t-digest of\r\ndeviations using the first t-digest's median and centroids\r\n\r\nFor #26681\r\n\r\nStill writing the docs, but wanted to get feedback on the code","created_at":"2018-10-15T18:52:08Z","updated_at":"2018-10-23T20:51:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed1e80f29e308810c7af44d1adb6221f0e1a34ff","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":141141324,"node_id":"MDU6TGFiZWwxNDExNDEzMjQ=","url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Search/Aggregations","name":":Search/Aggregations","color":"0e8a16","default":false},{"id":23172,"node_id":"MDU6TGFiZWwyMzE3Mg==","url":"https://api.github.com/repos/elastic/elasticsearch/labels/%3Efeature","name":">feature","color":"006b75","default":false},{"id":962378555,"node_id":"MDU6TGFiZWw5NjIzNzg1NTU=","url":"https://api.github.com/repos/elastic/elasticsearch/labels/v6.5.0","name":"v6.5.0","color":"Dddddd","default":false},{"id":484855464,"node_id":"MDU6TGFiZWw0ODQ4NTU0NjQ=","url":"https://api.github.com/repos/elastic/elasticsearch/labels/v7.0.0","name":"v7.0.0","color":"dddddd","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/34482/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/34482/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/34482/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/22deb4596c777d8f95a3b09c533534751bb6001f","head":{"label":"andyb-elastic:feature-mad-agg","ref":"feature-mad-agg","sha":"22deb4596c777d8f95a3b09c533534751bb6001f","user":{"login":"andyb-elastic","id":29205940,"node_id":"MDQ6VXNlcjI5MjA1OTQw","avatar_url":"https://avatars2.githubusercontent.com/u/29205940?v=4","gravatar_id":"","url":"https://api.github.com/users/andyb-elastic","html_url":"https://github.com/andyb-elastic","followers_url":"https://api.github.com/users/andyb-elastic/followers","following_url":"https://api.github.com/users/andyb-elastic/following{/other_user}","gists_url":"https://api.github.com/users/andyb-elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/andyb-elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyb-elastic/subscriptions","organizations_url":"https://api.github.com/users/andyb-elastic/orgs","repos_url":"https://api.github.com/users/andyb-elastic/repos","events_url":"https://api.github.com/users/andyb-elastic/events{/privacy}","received_events_url":"https://api.github.com/users/andyb-elastic/received_events","type":"User","site_admin":false},"repo":{"id":105077423,"node_id":"MDEwOlJlcG9zaXRvcnkxMDUwNzc0MjM=","name":"elasticsearch","full_name":"andyb-elastic/elasticsearch","private":false,"owner":{"login":"andyb-elastic","id":29205940,"node_id":"MDQ6VXNlcjI5MjA1OTQw","avatar_url":"https://avatars2.githubusercontent.com/u/29205940?v=4","gravatar_id":"","url":"https://api.github.com/users/andyb-elastic","html_url":"https://github.com/andyb-elastic","followers_url":"https://api.github.com/users/andyb-elastic/followers","following_url":"https://api.github.com/users/andyb-elastic/following{/other_user}","gists_url":"https://api.github.com/users/andyb-elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/andyb-elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyb-elastic/subscriptions","organizations_url":"https://api.github.com/users/andyb-elastic/orgs","repos_url":"https://api.github.com/users/andyb-elastic/repos","events_url":"https://api.github.com/users/andyb-elastic/events{/privacy}","received_events_url":"https://api.github.com/users/andyb-elastic/received_events","type":"User","site_admin":false},"html_url":"https://github.com/andyb-elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/andyb-elastic/elasticsearch","forks_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/andyb-elastic/elasticsearch/deployments","created_at":"2017-09-27T22:52:21Z","updated_at":"2017-09-27T22:53:02Z","pushed_at":"2018-10-23T18:11:38Z","git_url":"git://github.com/andyb-elastic/elasticsearch.git","ssh_url":"git@github.com:andyb-elastic/elasticsearch.git","clone_url":"https://github.com/andyb-elastic/elasticsearch.git","svn_url":"https://github.com/andyb-elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":499574,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"ed817fb2659d4a4adbe10601886cfcbacd153c7d","user":{"login":"elastic","id":6764390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NjQzOTA=","avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","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,"node_id":"MDEwOlJlcG9zaXRvcnk1MDc3NzU=","name":"elasticsearch","full_name":"elastic/elasticsearch","private":false,"owner":{"login":"elastic","id":6764390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NjQzOTA=","avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","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},"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":"2018-10-23T20:38:10Z","pushed_at":"2018-10-23T20:36:58Z","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":521409,"stargazers_count":35483,"watchers_count":35483,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":11991,"mirror_url":null,"archived":false,"open_issues_count":1768,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":11991,"open_issues":1768,"watchers":35483,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/34482"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/34482"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/34482"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/34482/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/34482/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/34482/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/22deb4596c777d8f95a3b09c533534751bb6001f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"polyfractal"}}