{"action":"opened","number":11465,"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/11465","id":36794363,"html_url":"https://github.com/elastic/elasticsearch/pull/11465","diff_url":"https://github.com/elastic/elasticsearch/pull/11465.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/11465.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11465","number":11465,"state":"open","locked":false,"title":"Aggregations: Fix bug where moving_avg prediction keys are appended to previous prediction","user":{"login":"polyfractal","id":1224228,"avatar_url":"https://avatars.githubusercontent.com/u/1224228?v=3","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":"Flow is now:\r\n\r\n1. Iterate over buckets, generating movavg values if possible\r\n2. If predictions are requested, a hashmap of keys is maintained for lookup later\r\n3. Track the last valid key (e.g. last key that had data)\r\n4. When a prediction is needed, we check in the map to see if the key is present.\r\n  1. If the key is present, we create a new bucket with the old aggs + new prediction and overwrite the existing bucket\r\n  2. If the key was not found, we simply generate a brand new bucket with the prediction\r\n5. Predictions are now appended to the end of the \"valid data\", rather than the end of the requested range.  This makes more sense anyway, and works nicely with the gap policies.\r\n\r\nThe map is needed to avoid doing constant binary searches over the list of buckets.  We may need to add an `execution_mode` that allows a bin-search in the future, in case the user is executing massive moving avgs and would prefer to trade CPU for memory.\r\n\r\nThe solution feels a little janky...happy to entertain a different solution.  If this looks reasonable, I'll work up some more test cases (movavgs with different predictions, 3+ movavgs, etc)\r\n\r\nFixes #11454","created_at":"2015-06-03T02:52:50Z","updated_at":"2015-06-03T02:52:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/11465/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/11465/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/11465/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/a60eec29e519ed148b8b02ef8514404738ac3f4f","head":{"label":"polyfractal:bugfix/movavg_double_predict","ref":"bugfix/movavg_double_predict","sha":"a60eec29e519ed148b8b02ef8514404738ac3f4f","user":{"login":"polyfractal","id":1224228,"avatar_url":"https://avatars.githubusercontent.com/u/1224228?v=3","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},"repo":{"id":7764033,"name":"elasticsearch","full_name":"polyfractal/elasticsearch","owner":{"login":"polyfractal","id":1224228,"avatar_url":"https://avatars.githubusercontent.com/u/1224228?v=3","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},"private":false,"html_url":"https://github.com/polyfractal/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/polyfractal/elasticsearch","forks_url":"https://api.github.com/repos/polyfractal/elasticsearch/forks","keys_url":"https://api.github.com/repos/polyfractal/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/polyfractal/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/polyfractal/elasticsearch/teams","hooks_url":"https://api.github.com/repos/polyfractal/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/polyfractal/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/polyfractal/elasticsearch/events","assignees_url":"https://api.github.com/repos/polyfractal/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/polyfractal/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/polyfractal/elasticsearch/tags","blobs_url":"https://api.github.com/repos/polyfractal/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/polyfractal/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/polyfractal/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/polyfractal/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/polyfractal/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/polyfractal/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/polyfractal/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/polyfractal/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/polyfractal/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/polyfractal/elasticsearch/subscription","commits_url":"https://api.github.com/repos/polyfractal/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/polyfractal/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/polyfractal/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/polyfractal/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/polyfractal/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/polyfractal/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/polyfractal/elasticsearch/merges","archive_url":"https://api.github.com/repos/polyfractal/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/polyfractal/elasticsearch/downloads","issues_url":"https://api.github.com/repos/polyfractal/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/polyfractal/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/polyfractal/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/polyfractal/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/polyfractal/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/polyfractal/elasticsearch/releases{/id}","created_at":"2013-01-22T23:47:55Z","updated_at":"2015-05-01T23:01:11Z","pushed_at":"2015-06-03T02:48:43Z","git_url":"git://github.com/polyfractal/elasticsearch.git","ssh_url":"git@github.com:polyfractal/elasticsearch.git","clone_url":"https://github.com/polyfractal/elasticsearch.git","svn_url":"https://github.com/polyfractal/elasticsearch","homepage":"http://elasticsearch.org","size":117313,"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":"59d9f7e1579ca70973d14e94da0b8794e60f3b85","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}","created_at":"2010-02-08T13:20:56Z","updated_at":"2015-06-03T02:21:10Z","pushed_at":"2015-06-03T00:26:26Z","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":1901235,"stargazers_count":11432,"watchers_count":11432,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3615,"mirror_url":null,"open_issues_count":1100,"forks":3615,"open_issues":1100,"watchers":11432,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/11465"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/11465"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/11465"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/11465/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/11465/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/11465/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/a60eec29e519ed148b8b02ef8514404738ac3f4f"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":169,"deletions":22,"changed_files":2}}