{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-druid/pulls/comments/221115110","pull_request_review_id":159687711,"id":221115110,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTExNTExMA==","diff_hunk":"@@ -621,4 +653,96 @@ private static DimensionSchema createDimensionSchema(\n       return usedSegments;\n     }\n   }\n+\n+  @VisibleForTesting\n+  static class PartitionConfigurationManager\n+  {\n+    @Nullable\n+    private final Long targetCompactionSizeBytes;\n+    @Nullable\n+    private final IndexTuningConfig tuningConfig;\n+\n+    PartitionConfigurationManager(@Nullable Long targetCompactionSizeBytes, @Nullable IndexTuningConfig tuningConfig)\n+    {\n+      this.targetCompactionSizeBytes = getValidTargetCompactionSizeBytes(targetCompactionSizeBytes, tuningConfig);\n+      this.tuningConfig = tuningConfig;\n+    }\n+\n+    @Nullable\n+    IndexTuningConfig computeTuningConfig(List<Pair<QueryableIndex, DataSegment>> queryableIndexAndSegments)\n+    {\n+      if (!hasPartitionConfig(tuningConfig)) {\n+        // Find IndexTuningConfig.targetPartitionSize which is the number of rows per segment.\n+        // Assume that the segment size is proportional to the number of rows. We can improve this later.\n+        final double avgRowsPerByte = queryableIndexAndSegments\n+            .stream()\n+            .mapToDouble(queryableIndexAndDataSegment -> {\n+              final long numRows = queryableIndexAndDataSegment.lhs.getNumRows();\n+              final long size = queryableIndexAndDataSegment.rhs.getSize();\n+              return numRows / (double) size;\n+            })\n+            .average()\n+            .orElseThrow(() -> new ISE(\"Cannot find targetPartitionSize because the input segment is empty\"));\n+        final int targetPartitionSize = (int) Math.round(avgRowsPerByte * targetCompactionSizeBytes);\n+        Preconditions.checkState(targetPartitionSize > 0, \"Negative targetPartitionSize[%s]\", targetPartitionSize);","path":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java","position":262,"original_position":253,"commit_id":"00336fb0190c6876f3599caa8a0ac04087fc533c","original_commit_id":"e59961b493c5848052aac2199aabbb4a8e3d2560","user":{"login":"jihoonson","id":2322288,"node_id":"MDQ6VXNlcjIzMjIyODg=","avatar_url":"https://avatars3.githubusercontent.com/u/2322288?v=4","gravatar_id":"","url":"https://api.github.com/users/jihoonson","html_url":"https://github.com/jihoonson","followers_url":"https://api.github.com/users/jihoonson/followers","following_url":"https://api.github.com/users/jihoonson/following{/other_user}","gists_url":"https://api.github.com/users/jihoonson/gists{/gist_id}","starred_url":"https://api.github.com/users/jihoonson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jihoonson/subscriptions","organizations_url":"https://api.github.com/users/jihoonson/orgs","repos_url":"https://api.github.com/users/jihoonson/repos","events_url":"https://api.github.com/users/jihoonson/events{/privacy}","received_events_url":"https://api.github.com/users/jihoonson/received_events","type":"User","site_admin":false},"body":"Good point. Fixed.","created_at":"2018-09-28T00:32:34Z","updated_at":"2018-09-28T00:32:34Z","html_url":"https://github.com/apache/incubator-druid/pull/6203#discussion_r221115110","pull_request_url":"https://api.github.com/repos/apache/incubator-druid/pulls/6203","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/comments/221115110"},"html":{"href":"https://github.com/apache/incubator-druid/pull/6203#discussion_r221115110"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/6203"}},"in_reply_to_id":220729042},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-druid/pulls/6203","id":209944096,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5OTQ0MDk2","html_url":"https://github.com/apache/incubator-druid/pull/6203","diff_url":"https://github.com/apache/incubator-druid/pull/6203.diff","patch_url":"https://github.com/apache/incubator-druid/pull/6203.patch","issue_url":"https://api.github.com/repos/apache/incubator-druid/issues/6203","number":6203,"state":"open","locked":false,"title":"Add support targetCompactionSizeBytes for compactionTask","user":{"login":"jihoonson","id":2322288,"node_id":"MDQ6VXNlcjIzMjIyODg=","avatar_url":"https://avatars3.githubusercontent.com/u/2322288?v=4","gravatar_id":"","url":"https://api.github.com/users/jihoonson","html_url":"https://github.com/jihoonson","followers_url":"https://api.github.com/users/jihoonson/followers","following_url":"https://api.github.com/users/jihoonson/following{/other_user}","gists_url":"https://api.github.com/users/jihoonson/gists{/gist_id}","starred_url":"https://api.github.com/users/jihoonson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jihoonson/subscriptions","organizations_url":"https://api.github.com/users/jihoonson/orgs","repos_url":"https://api.github.com/users/jihoonson/repos","events_url":"https://api.github.com/users/jihoonson/events{/privacy}","received_events_url":"https://api.github.com/users/jihoonson/received_events","type":"User","site_admin":false},"body":"`targetCompactionSizeBytes` is similar to that of automatic compaction and means the size of the result segments after compaction. This is especially useful to compact a large interval partition into a few segments of the optimal size. A large interval partition means that the total size of segments in that partition is larger than `targetCompactionSizeBytes` no matter what the number of segments is.\r\n\r\nSince indexTask doesn't support a sort configuration for target segment size, compactionTask assumes that the segment size is proportional to the number of rows in the segment and automatically computes `targetPartitionSize` based on the given `targetCompactionSizeBytes`. This assumption is pretty naive, so we can improve it later.\r\n\r\n`targetCompactionSizeBytes` cannot be used together with `targetPartitionSize`, `maxTotalRows`, or `numShards` in `IndexTuningConfig`. If both are set, compactionTask will throw an exception and fail. If both are not set, `targetCompactionSizeBytes` is set to default (400MB).","created_at":"2018-08-21T20:19:53Z","updated_at":"2018-09-28T00:32:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"48d0320d935ba47ab95d15a41f9a62bce732eccb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/apache/incubator-druid/milestones/25","html_url":"https://github.com/apache/incubator-druid/milestone/25","labels_url":"https://api.github.com/repos/apache/incubator-druid/milestones/25/labels","id":3023864,"node_id":"MDk6TWlsZXN0b25lMzAyMzg2NA==","number":25,"title":"0.13.0","description":"","creator":{"login":"leventov","id":609240,"node_id":"MDQ6VXNlcjYwOTI0MA==","avatar_url":"https://avatars0.githubusercontent.com/u/609240?v=4","gravatar_id":"","url":"https://api.github.com/users/leventov","html_url":"https://github.com/leventov","followers_url":"https://api.github.com/users/leventov/followers","following_url":"https://api.github.com/users/leventov/following{/other_user}","gists_url":"https://api.github.com/users/leventov/gists{/gist_id}","starred_url":"https://api.github.com/users/leventov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leventov/subscriptions","organizations_url":"https://api.github.com/users/leventov/orgs","repos_url":"https://api.github.com/users/leventov/repos","events_url":"https://api.github.com/users/leventov/events{/privacy}","received_events_url":"https://api.github.com/users/leventov/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":140,"state":"open","created_at":"2018-01-09T18:30:01Z","updated_at":"2018-09-28T00:21:35Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/apache/incubator-druid/pulls/6203/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-druid/pulls/6203/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-druid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-druid/issues/6203/comments","statuses_url":"https://api.github.com/repos/apache/incubator-druid/statuses/00336fb0190c6876f3599caa8a0ac04087fc533c","head":{"label":"jihoonson:target_compact_size_for_compact_task","ref":"target_compact_size_for_compact_task","sha":"00336fb0190c6876f3599caa8a0ac04087fc533c","user":{"login":"jihoonson","id":2322288,"node_id":"MDQ6VXNlcjIzMjIyODg=","avatar_url":"https://avatars3.githubusercontent.com/u/2322288?v=4","gravatar_id":"","url":"https://api.github.com/users/jihoonson","html_url":"https://github.com/jihoonson","followers_url":"https://api.github.com/users/jihoonson/followers","following_url":"https://api.github.com/users/jihoonson/following{/other_user}","gists_url":"https://api.github.com/users/jihoonson/gists{/gist_id}","starred_url":"https://api.github.com/users/jihoonson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jihoonson/subscriptions","organizations_url":"https://api.github.com/users/jihoonson/orgs","repos_url":"https://api.github.com/users/jihoonson/repos","events_url":"https://api.github.com/users/jihoonson/events{/privacy}","received_events_url":"https://api.github.com/users/jihoonson/received_events","type":"User","site_admin":false},"repo":{"id":71565181,"node_id":"MDEwOlJlcG9zaXRvcnk3MTU2NTE4MQ==","name":"druid","full_name":"jihoonson/druid","private":false,"owner":{"login":"jihoonson","id":2322288,"node_id":"MDQ6VXNlcjIzMjIyODg=","avatar_url":"https://avatars3.githubusercontent.com/u/2322288?v=4","gravatar_id":"","url":"https://api.github.com/users/jihoonson","html_url":"https://github.com/jihoonson","followers_url":"https://api.github.com/users/jihoonson/followers","following_url":"https://api.github.com/users/jihoonson/following{/other_user}","gists_url":"https://api.github.com/users/jihoonson/gists{/gist_id}","starred_url":"https://api.github.com/users/jihoonson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jihoonson/subscriptions","organizations_url":"https://api.github.com/users/jihoonson/orgs","repos_url":"https://api.github.com/users/jihoonson/repos","events_url":"https://api.github.com/users/jihoonson/events{/privacy}","received_events_url":"https://api.github.com/users/jihoonson/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jihoonson/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":true,"url":"https://api.github.com/repos/jihoonson/druid","forks_url":"https://api.github.com/repos/jihoonson/druid/forks","keys_url":"https://api.github.com/repos/jihoonson/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jihoonson/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jihoonson/druid/teams","hooks_url":"https://api.github.com/repos/jihoonson/druid/hooks","issue_events_url":"https://api.github.com/repos/jihoonson/druid/issues/events{/number}","events_url":"https://api.github.com/repos/jihoonson/druid/events","assignees_url":"https://api.github.com/repos/jihoonson/druid/assignees{/user}","branches_url":"https://api.github.com/repos/jihoonson/druid/branches{/branch}","tags_url":"https://api.github.com/repos/jihoonson/druid/tags","blobs_url":"https://api.github.com/repos/jihoonson/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jihoonson/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jihoonson/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/jihoonson/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jihoonson/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/jihoonson/druid/languages","stargazers_url":"https://api.github.com/repos/jihoonson/druid/stargazers","contributors_url":"https://api.github.com/repos/jihoonson/druid/contributors","subscribers_url":"https://api.github.com/repos/jihoonson/druid/subscribers","subscription_url":"https://api.github.com/repos/jihoonson/druid/subscription","commits_url":"https://api.github.com/repos/jihoonson/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/jihoonson/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/jihoonson/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/jihoonson/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/jihoonson/druid/contents/{+path}","compare_url":"https://api.github.com/repos/jihoonson/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jihoonson/druid/merges","archive_url":"https://api.github.com/repos/jihoonson/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jihoonson/druid/downloads","issues_url":"https://api.github.com/repos/jihoonson/druid/issues{/number}","pulls_url":"https://api.github.com/repos/jihoonson/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/jihoonson/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/jihoonson/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jihoonson/druid/labels{/name}","releases_url":"https://api.github.com/repos/jihoonson/druid/releases{/id}","deployments_url":"https://api.github.com/repos/jihoonson/druid/deployments","created_at":"2016-10-21T13:05:19Z","updated_at":"2018-07-06T15:32:53Z","pushed_at":"2018-09-28T00:32:19Z","git_url":"git://github.com/jihoonson/druid.git","ssh_url":"git@github.com:jihoonson/druid.git","clone_url":"https://github.com/jihoonson/druid.git","svn_url":"https://github.com/jihoonson/druid","homepage":"http://druid.io","size":150240,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"apache:master","ref":"master","sha":"f12ffd19a860a714fdc0a6f173ec8aea5dc44ddd","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":6358188,"node_id":"MDEwOlJlcG9zaXRvcnk2MzU4MTg4","name":"incubator-druid","full_name":"apache/incubator-druid","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/apache/incubator-druid","description":"Apache Druid (Incubating) - Column oriented distributed data store ideal for powering interactive applications","fork":false,"url":"https://api.github.com/repos/apache/incubator-druid","forks_url":"https://api.github.com/repos/apache/incubator-druid/forks","keys_url":"https://api.github.com/repos/apache/incubator-druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-druid/teams","hooks_url":"https://api.github.com/repos/apache/incubator-druid/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-druid/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-druid/events","assignees_url":"https://api.github.com/repos/apache/incubator-druid/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-druid/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-druid/tags","blobs_url":"https://api.github.com/repos/apache/incubator-druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-druid/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-druid/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-druid/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-druid/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-druid/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-druid/subscription","commits_url":"https://api.github.com/repos/apache/incubator-druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-druid/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-druid/merges","archive_url":"https://api.github.com/repos/apache/incubator-druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-druid/downloads","issues_url":"https://api.github.com/repos/apache/incubator-druid/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-druid/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-druid/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-druid/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-druid/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-druid/deployments","created_at":"2012-10-23T19:08:07Z","updated_at":"2018-09-27T18:25:38Z","pushed_at":"2018-09-28T00:32:22Z","git_url":"git://github.com/apache/incubator-druid.git","ssh_url":"git@github.com:apache/incubator-druid.git","clone_url":"https://github.com/apache/incubator-druid.git","svn_url":"https://github.com/apache/incubator-druid","homepage":"http://druid.io","size":148055,"stargazers_count":7031,"watchers_count":7031,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1728,"mirror_url":null,"archived":false,"open_issues_count":1157,"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":1728,"open_issues":1157,"watchers":7031,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/6203"},"html":{"href":"https://github.com/apache/incubator-druid/pull/6203"},"issue":{"href":"https://api.github.com/repos/apache/incubator-druid/issues/6203"},"comments":{"href":"https://api.github.com/repos/apache/incubator-druid/issues/6203/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/6203/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-druid/pulls/6203/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-druid/statuses/00336fb0190c6876f3599caa8a0ac04087fc533c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jihoonson"}}