{"action":"created","comment":{"url":"https://api.github.com/repos/druid-io/druid/pulls/comments/49512118","id":49512118,"diff_hunk":"@@ -330,14 +329,22 @@ public String apply(@Nullable String input)\n           }\n         }\n     );\n-    if (mergedMetrics.size() != metricAggs.length) {\n-      throw new IAE(\"Bad number of metrics[%d], expected [%d]\", mergedMetrics.size(), metricAggs.length);\n+\n+    if (mergedMetrics.size() > metricAggs.length) {\n+      throw new IAE(\"Bad number of metrics[%d]. Union of metrics in indices is [%d]\", metricAggs.length, mergedMetrics.size());\n     }\n \n     final AggregatorFactory[] sortedMetricAggs = new AggregatorFactory[mergedMetrics.size()];\n     for (int i = 0; i < metricAggs.length; i++) {\n       AggregatorFactory metricAgg = metricAggs[i];\n-      sortedMetricAggs[mergedMetrics.indexOf(metricAgg.getName())] = metricAgg;\n+      int metricIndex = mergedMetrics.indexOf(metricAgg.getName());\n+      /*\n+        If metricIndex is negative, one of the metricAggs was not present in the union of metrics from the indices\n+        we are merging\n+       */\n+      if (metricIndex > -1) {\n+        sortedMetricAggs[mergedMetrics.indexOf(metricAgg.getName())] = metricAgg;","path":"processing/src/main/java/io/druid/segment/IndexMerger.java","position":29,"original_position":29,"commit_id":"36d02d3f3af5bd4e3271818e1ff652f4da9e6e6f","original_commit_id":"36d02d3f3af5bd4e3271818e1ff652f4da9e6e6f","user":{"login":"drcrallen","id":8213081,"avatar_url":"https://avatars.githubusercontent.com/u/8213081?v=3","gravatar_id":"","url":"https://api.github.com/users/drcrallen","html_url":"https://github.com/drcrallen","followers_url":"https://api.github.com/users/drcrallen/followers","following_url":"https://api.github.com/users/drcrallen/following{/other_user}","gists_url":"https://api.github.com/users/drcrallen/gists{/gist_id}","starred_url":"https://api.github.com/users/drcrallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drcrallen/subscriptions","organizations_url":"https://api.github.com/users/drcrallen/orgs","repos_url":"https://api.github.com/users/drcrallen/repos","events_url":"https://api.github.com/users/drcrallen/events{/privacy}","received_events_url":"https://api.github.com/users/drcrallen/received_events","type":"User","site_admin":false},"body":"Just beneath here metricAggs is used to fetch the name instead of sortedMetricAggs, which seems odd. Can you add some more tests that vary the missing value? maybe an A, B, C metrics where you remove A or B or C, or only have A or B or C?","created_at":"2016-01-12T20:57:28Z","updated_at":"2016-01-12T20:57:28Z","html_url":"https://github.com/druid-io/druid/pull/2257#discussion_r49512118","pull_request_url":"https://api.github.com/repos/druid-io/druid/pulls/2257","_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments/49512118"},"html":{"href":"https://github.com/druid-io/druid/pull/2257#discussion_r49512118"},"pull_request":{"href":"https://api.github.com/repos/druid-io/druid/pulls/2257"}}},"pull_request":{"url":"https://api.github.com/repos/druid-io/druid/pulls/2257","id":55808881,"html_url":"https://github.com/druid-io/druid/pull/2257","diff_url":"https://github.com/druid-io/druid/pull/2257.diff","patch_url":"https://github.com/druid-io/druid/pull/2257.patch","issue_url":"https://api.github.com/repos/druid-io/druid/issues/2257","number":2257,"state":"open","locked":false,"title":"Adds support for empty merge metrics. fixes #2256","user":{"login":"michaelschiff","id":1669670,"avatar_url":"https://avatars.githubusercontent.com/u/1669670?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelschiff","html_url":"https://github.com/michaelschiff","followers_url":"https://api.github.com/users/michaelschiff/followers","following_url":"https://api.github.com/users/michaelschiff/following{/other_user}","gists_url":"https://api.github.com/users/michaelschiff/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelschiff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelschiff/subscriptions","organizations_url":"https://api.github.com/users/michaelschiff/orgs","repos_url":"https://api.github.com/users/michaelschiff/repos","events_url":"https://api.github.com/users/michaelschiff/events{/privacy}","received_events_url":"https://api.github.com/users/michaelschiff/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-12T20:01:46Z","updated_at":"2016-01-12T20:57:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5c538f07ae2915e983784c56a6a52bc92ee2a3d6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/druid-io/druid/pulls/2257/commits","review_comments_url":"https://api.github.com/repos/druid-io/druid/pulls/2257/comments","review_comment_url":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/druid-io/druid/issues/2257/comments","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/36d02d3f3af5bd4e3271818e1ff652f4da9e6e6f","head":{"label":"tubemogul:index-merge-bug","ref":"index-merge-bug","sha":"36d02d3f3af5bd4e3271818e1ff652f4da9e6e6f","user":{"login":"tubemogul","id":918427,"avatar_url":"https://avatars.githubusercontent.com/u/918427?v=3","gravatar_id":"","url":"https://api.github.com/users/tubemogul","html_url":"https://github.com/tubemogul","followers_url":"https://api.github.com/users/tubemogul/followers","following_url":"https://api.github.com/users/tubemogul/following{/other_user}","gists_url":"https://api.github.com/users/tubemogul/gists{/gist_id}","starred_url":"https://api.github.com/users/tubemogul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tubemogul/subscriptions","organizations_url":"https://api.github.com/users/tubemogul/orgs","repos_url":"https://api.github.com/users/tubemogul/repos","events_url":"https://api.github.com/users/tubemogul/events{/privacy}","received_events_url":"https://api.github.com/users/tubemogul/received_events","type":"Organization","site_admin":false},"repo":{"id":38096137,"name":"druid","full_name":"tubemogul/druid","owner":{"login":"tubemogul","id":918427,"avatar_url":"https://avatars.githubusercontent.com/u/918427?v=3","gravatar_id":"","url":"https://api.github.com/users/tubemogul","html_url":"https://github.com/tubemogul","followers_url":"https://api.github.com/users/tubemogul/followers","following_url":"https://api.github.com/users/tubemogul/following{/other_user}","gists_url":"https://api.github.com/users/tubemogul/gists{/gist_id}","starred_url":"https://api.github.com/users/tubemogul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tubemogul/subscriptions","organizations_url":"https://api.github.com/users/tubemogul/orgs","repos_url":"https://api.github.com/users/tubemogul/repos","events_url":"https://api.github.com/users/tubemogul/events{/privacy}","received_events_url":"https://api.github.com/users/tubemogul/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tubemogul/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":true,"url":"https://api.github.com/repos/tubemogul/druid","forks_url":"https://api.github.com/repos/tubemogul/druid/forks","keys_url":"https://api.github.com/repos/tubemogul/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tubemogul/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tubemogul/druid/teams","hooks_url":"https://api.github.com/repos/tubemogul/druid/hooks","issue_events_url":"https://api.github.com/repos/tubemogul/druid/issues/events{/number}","events_url":"https://api.github.com/repos/tubemogul/druid/events","assignees_url":"https://api.github.com/repos/tubemogul/druid/assignees{/user}","branches_url":"https://api.github.com/repos/tubemogul/druid/branches{/branch}","tags_url":"https://api.github.com/repos/tubemogul/druid/tags","blobs_url":"https://api.github.com/repos/tubemogul/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tubemogul/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tubemogul/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/tubemogul/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tubemogul/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/tubemogul/druid/languages","stargazers_url":"https://api.github.com/repos/tubemogul/druid/stargazers","contributors_url":"https://api.github.com/repos/tubemogul/druid/contributors","subscribers_url":"https://api.github.com/repos/tubemogul/druid/subscribers","subscription_url":"https://api.github.com/repos/tubemogul/druid/subscription","commits_url":"https://api.github.com/repos/tubemogul/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/tubemogul/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/tubemogul/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/tubemogul/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/tubemogul/druid/contents/{+path}","compare_url":"https://api.github.com/repos/tubemogul/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tubemogul/druid/merges","archive_url":"https://api.github.com/repos/tubemogul/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tubemogul/druid/downloads","issues_url":"https://api.github.com/repos/tubemogul/druid/issues{/number}","pulls_url":"https://api.github.com/repos/tubemogul/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/tubemogul/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/tubemogul/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tubemogul/druid/labels{/name}","releases_url":"https://api.github.com/repos/tubemogul/druid/releases{/id}","created_at":"2015-06-26T07:01:11Z","updated_at":"2016-01-12T16:53:58Z","pushed_at":"2016-01-12T19:59:12Z","git_url":"git://github.com/tubemogul/druid.git","ssh_url":"git@github.com:tubemogul/druid.git","clone_url":"https://github.com/tubemogul/druid.git","svn_url":"https://github.com/tubemogul/druid","homepage":"http://druid.io","size":99796,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"druid-io:master","ref":"master","sha":"01a0715ee29b4d819a0518769afe170e741ddc2e","user":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"repo":{"id":6358188,"name":"druid","full_name":"druid-io/druid","owner":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/druid-io/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":false,"url":"https://api.github.com/repos/druid-io/druid","forks_url":"https://api.github.com/repos/druid-io/druid/forks","keys_url":"https://api.github.com/repos/druid-io/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/druid-io/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/druid-io/druid/teams","hooks_url":"https://api.github.com/repos/druid-io/druid/hooks","issue_events_url":"https://api.github.com/repos/druid-io/druid/issues/events{/number}","events_url":"https://api.github.com/repos/druid-io/druid/events","assignees_url":"https://api.github.com/repos/druid-io/druid/assignees{/user}","branches_url":"https://api.github.com/repos/druid-io/druid/branches{/branch}","tags_url":"https://api.github.com/repos/druid-io/druid/tags","blobs_url":"https://api.github.com/repos/druid-io/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/druid-io/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/druid-io/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/druid-io/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/druid-io/druid/languages","stargazers_url":"https://api.github.com/repos/druid-io/druid/stargazers","contributors_url":"https://api.github.com/repos/druid-io/druid/contributors","subscribers_url":"https://api.github.com/repos/druid-io/druid/subscribers","subscription_url":"https://api.github.com/repos/druid-io/druid/subscription","commits_url":"https://api.github.com/repos/druid-io/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/druid-io/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/druid-io/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/druid-io/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/druid-io/druid/contents/{+path}","compare_url":"https://api.github.com/repos/druid-io/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/druid-io/druid/merges","archive_url":"https://api.github.com/repos/druid-io/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/druid-io/druid/downloads","issues_url":"https://api.github.com/repos/druid-io/druid/issues{/number}","pulls_url":"https://api.github.com/repos/druid-io/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/druid-io/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/druid-io/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/druid-io/druid/labels{/name}","releases_url":"https://api.github.com/repos/druid-io/druid/releases{/id}","created_at":"2012-10-23T19:08:07Z","updated_at":"2016-01-12T16:19:13Z","pushed_at":"2016-01-12T20:01:46Z","git_url":"git://github.com/druid-io/druid.git","ssh_url":"git@github.com:druid-io/druid.git","clone_url":"https://github.com/druid-io/druid.git","svn_url":"https://github.com/druid-io/druid","homepage":"http://druid.io","size":122163,"stargazers_count":2349,"watchers_count":2349,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":552,"mirror_url":null,"open_issues_count":286,"forks":552,"open_issues":286,"watchers":2349,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/2257"},"html":{"href":"https://github.com/druid-io/druid/pull/2257"},"issue":{"href":"https://api.github.com/repos/druid-io/druid/issues/2257"},"comments":{"href":"https://api.github.com/repos/druid-io/druid/issues/2257/comments"},"review_comments":{"href":"https://api.github.com/repos/druid-io/druid/pulls/2257/comments"},"review_comment":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/druid-io/druid/pulls/2257/commits"},"statuses":{"href":"https://api.github.com/repos/druid-io/druid/statuses/36d02d3f3af5bd4e3271818e1ff652f4da9e6e6f"}}}}