{"action":"created","comment":{"url":"https://api.github.com/repos/linkedin/gobblin/pulls/comments/30856056","id":30856056,"diff_hunk":"@@ -0,0 +1,150 @@\n+/* (c) 2015 LinkedIn Corp. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use\n+ * this file except in compliance with the License. You may obtain a copy of the\n+ * License at  http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software distributed\n+ * under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n+ * CONDITIONS OF ANY KIND, either express or implied.\n+ */\n+\n+package gobblin.source.extractor.extract.kafka;\n+\n+import java.math.RoundingMode;\n+import java.util.List;\n+\n+import com.beust.jcommander.internal.Lists;\n+import com.google.common.base.Preconditions;\n+import com.google.common.collect.ComparisonChain;\n+import com.google.common.math.LongMath;\n+import com.google.common.primitives.Shorts;\n+import com.google.gson.Gson;\n+import com.google.gson.JsonElement;\n+\n+import gobblin.source.extractor.Watermark;\n+\n+\n+/**\n+ * A {@link gobblin.source.extractor.Watermark} that holds multiple long values.\n+ *\n+ * @author ziliu\n+ */\n+public class MultiLongWatermark implements Watermark {\n+\n+  private static final Gson GSON = new Gson();\n+\n+  private final List<Long> values;\n+\n+  /**\n+   * Copy constructor.\n+   */\n+  public MultiLongWatermark(MultiLongWatermark other) {\n+    this.values = Lists.newArrayList(other.values);","path":"gobblin-core/src/main/java/gobblin/source/extractor/extract/kafka/MultiLongWatermark.java","position":43,"original_position":43,"commit_id":"c80ef7e0b47310b9b0427f28a24d30df3265e38c","original_commit_id":"c80ef7e0b47310b9b0427f28a24d30df3265e38c","user":{"login":"tuGithub","id":9965624,"avatar_url":"https://avatars.githubusercontent.com/u/9965624?v=3","gravatar_id":"","url":"https://api.github.com/users/tuGithub","html_url":"https://github.com/tuGithub","followers_url":"https://api.github.com/users/tuGithub/followers","following_url":"https://api.github.com/users/tuGithub/following{/other_user}","gists_url":"https://api.github.com/users/tuGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/tuGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuGithub/subscriptions","organizations_url":"https://api.github.com/users/tuGithub/orgs","repos_url":"https://api.github.com/users/tuGithub/repos","events_url":"https://api.github.com/users/tuGithub/events{/privacy}","received_events_url":"https://api.github.com/users/tuGithub/received_events","type":"User","site_admin":false},"body":"Consider use java native:\r\n\r\nthis.values =new ArrayList<Long>(other.values);","created_at":"2015-05-21T22:50:01Z","updated_at":"2015-05-21T22:50:01Z","html_url":"https://github.com/linkedin/gobblin/pull/135#discussion_r30856056","pull_request_url":"https://api.github.com/repos/linkedin/gobblin/pulls/135","_links":{"self":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/comments/30856056"},"html":{"href":"https://github.com/linkedin/gobblin/pull/135#discussion_r30856056"},"pull_request":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/135"}}},"pull_request":{"url":"https://api.github.com/repos/linkedin/gobblin/pulls/135","id":35692936,"html_url":"https://github.com/linkedin/gobblin/pull/135","diff_url":"https://github.com/linkedin/gobblin/pull/135.diff","patch_url":"https://github.com/linkedin/gobblin/pull/135.patch","issue_url":"https://api.github.com/repos/linkedin/gobblin/issues/135","number":135,"state":"open","locked":false,"title":"Refactor Kafka adapter for complex watermark","user":{"login":"zliu41","id":6342538,"avatar_url":"https://avatars.githubusercontent.com/u/6342538?v=3","gravatar_id":"","url":"https://api.github.com/users/zliu41","html_url":"https://github.com/zliu41","followers_url":"https://api.github.com/users/zliu41/followers","following_url":"https://api.github.com/users/zliu41/following{/other_user}","gists_url":"https://api.github.com/users/zliu41/gists{/gist_id}","starred_url":"https://api.github.com/users/zliu41/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zliu41/subscriptions","organizations_url":"https://api.github.com/users/zliu41/orgs","repos_url":"https://api.github.com/users/zliu41/repos","events_url":"https://api.github.com/users/zliu41/events{/privacy}","received_events_url":"https://api.github.com/users/zliu41/received_events","type":"User","site_admin":false},"body":"- Refactored `KafkaSource` and `KafkaExtractor` for the complex watermark:\r\n\r\nNow each WorkUnit in a MultiWorkUnit returned by `KafkaSource.getWorkUnits()` is\r\nresponsible for pulling multiple Kafka partitions of the same topic, so that\r\nthese partitions can share output files rather than creating its own output files.\r\n\r\nTo this end, a method `KafkaSource.squeezeMultiWorkUnits()` is added to combine all WorkUnits in a MultiWorkUnit into a single WorkUnit.\r\n\r\n`KafkaExtractor.readRecord()` is rewritten to pull from multiple partitions.\r\n\r\n\r\n- Small modification to complex watermark:\r\n\r\n  - Changed the implementation of `WorkUnit.getLowWatermark` and\r\n`WorkUnit.getExpectedHighWatermark`. The original implementation doesn't work and\r\nthrows \"Not a JsonObject\" exceptions. \r\n  - Changed return type of\r\n`WorkUnitState.getActualHighWatermark()` from `JsonElement` to `String`. In the\r\noriginal implementation, `GSON.toJsonTree(String)` will convert `\"` in the input\r\nstring to `\\\"` in the JsonElement, which will break if we pass this JsonElement to GSON.fromJson.\r\n  - Added method `setWatermarkInterval` to `SourceState`, since we need a way to assign watermarks to workunits.\r\n\r\n- Modified the best fit implementation in KafkaSource, the original one was incorrect.\r\n\r\n- Modified the worst fit implementation in KafkaSource, using a MinMaxPriorityQueue to improve efficiency.\r\n\r\n- Use `com.google.common.net.HostAndPort`\r\n\r\n- Other small refactoring for better readability.","created_at":"2015-05-19T03:17:32Z","updated_at":"2015-05-21T22:50:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fda3b077c477ecddd992b5de6aedf652c911d16b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linkedin/gobblin/pulls/135/commits","review_comments_url":"https://api.github.com/repos/linkedin/gobblin/pulls/135/comments","review_comment_url":"https://api.github.com/repos/linkedin/gobblin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linkedin/gobblin/issues/135/comments","statuses_url":"https://api.github.com/repos/linkedin/gobblin/statuses/c80ef7e0b47310b9b0427f28a24d30df3265e38c","head":{"label":"zliu41:newWm","ref":"newWm","sha":"c80ef7e0b47310b9b0427f28a24d30df3265e38c","user":{"login":"zliu41","id":6342538,"avatar_url":"https://avatars.githubusercontent.com/u/6342538?v=3","gravatar_id":"","url":"https://api.github.com/users/zliu41","html_url":"https://github.com/zliu41","followers_url":"https://api.github.com/users/zliu41/followers","following_url":"https://api.github.com/users/zliu41/following{/other_user}","gists_url":"https://api.github.com/users/zliu41/gists{/gist_id}","starred_url":"https://api.github.com/users/zliu41/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zliu41/subscriptions","organizations_url":"https://api.github.com/users/zliu41/orgs","repos_url":"https://api.github.com/users/zliu41/repos","events_url":"https://api.github.com/users/zliu41/events{/privacy}","received_events_url":"https://api.github.com/users/zliu41/received_events","type":"User","site_admin":false},"repo":{"id":32048123,"name":"gobblin","full_name":"zliu41/gobblin","owner":{"login":"zliu41","id":6342538,"avatar_url":"https://avatars.githubusercontent.com/u/6342538?v=3","gravatar_id":"","url":"https://api.github.com/users/zliu41","html_url":"https://github.com/zliu41","followers_url":"https://api.github.com/users/zliu41/followers","following_url":"https://api.github.com/users/zliu41/following{/other_user}","gists_url":"https://api.github.com/users/zliu41/gists{/gist_id}","starred_url":"https://api.github.com/users/zliu41/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zliu41/subscriptions","organizations_url":"https://api.github.com/users/zliu41/orgs","repos_url":"https://api.github.com/users/zliu41/repos","events_url":"https://api.github.com/users/zliu41/events{/privacy}","received_events_url":"https://api.github.com/users/zliu41/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zliu41/gobblin","description":"","fork":true,"url":"https://api.github.com/repos/zliu41/gobblin","forks_url":"https://api.github.com/repos/zliu41/gobblin/forks","keys_url":"https://api.github.com/repos/zliu41/gobblin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zliu41/gobblin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zliu41/gobblin/teams","hooks_url":"https://api.github.com/repos/zliu41/gobblin/hooks","issue_events_url":"https://api.github.com/repos/zliu41/gobblin/issues/events{/number}","events_url":"https://api.github.com/repos/zliu41/gobblin/events","assignees_url":"https://api.github.com/repos/zliu41/gobblin/assignees{/user}","branches_url":"https://api.github.com/repos/zliu41/gobblin/branches{/branch}","tags_url":"https://api.github.com/repos/zliu41/gobblin/tags","blobs_url":"https://api.github.com/repos/zliu41/gobblin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zliu41/gobblin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zliu41/gobblin/git/refs{/sha}","trees_url":"https://api.github.com/repos/zliu41/gobblin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zliu41/gobblin/statuses/{sha}","languages_url":"https://api.github.com/repos/zliu41/gobblin/languages","stargazers_url":"https://api.github.com/repos/zliu41/gobblin/stargazers","contributors_url":"https://api.github.com/repos/zliu41/gobblin/contributors","subscribers_url":"https://api.github.com/repos/zliu41/gobblin/subscribers","subscription_url":"https://api.github.com/repos/zliu41/gobblin/subscription","commits_url":"https://api.github.com/repos/zliu41/gobblin/commits{/sha}","git_commits_url":"https://api.github.com/repos/zliu41/gobblin/git/commits{/sha}","comments_url":"https://api.github.com/repos/zliu41/gobblin/comments{/number}","issue_comment_url":"https://api.github.com/repos/zliu41/gobblin/issues/comments{/number}","contents_url":"https://api.github.com/repos/zliu41/gobblin/contents/{+path}","compare_url":"https://api.github.com/repos/zliu41/gobblin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zliu41/gobblin/merges","archive_url":"https://api.github.com/repos/zliu41/gobblin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zliu41/gobblin/downloads","issues_url":"https://api.github.com/repos/zliu41/gobblin/issues{/number}","pulls_url":"https://api.github.com/repos/zliu41/gobblin/pulls{/number}","milestones_url":"https://api.github.com/repos/zliu41/gobblin/milestones{/number}","notifications_url":"https://api.github.com/repos/zliu41/gobblin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zliu41/gobblin/labels{/name}","releases_url":"https://api.github.com/repos/zliu41/gobblin/releases{/id}","created_at":"2015-03-12T00:17:48Z","updated_at":"2015-05-07T16:27:07Z","pushed_at":"2015-05-21T00:10:53Z","git_url":"git://github.com/zliu41/gobblin.git","ssh_url":"git@github.com:zliu41/gobblin.git","clone_url":"https://github.com/zliu41/gobblin.git","svn_url":"https://github.com/zliu41/gobblin","homepage":null,"size":77118,"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":"linkedin:master","ref":"master","sha":"9f0de2317b03141679dd2be1ad0506941a878d43","user":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"repo":{"id":27392543,"name":"gobblin","full_name":"linkedin/gobblin","owner":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linkedin/gobblin","description":"","fork":false,"url":"https://api.github.com/repos/linkedin/gobblin","forks_url":"https://api.github.com/repos/linkedin/gobblin/forks","keys_url":"https://api.github.com/repos/linkedin/gobblin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linkedin/gobblin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linkedin/gobblin/teams","hooks_url":"https://api.github.com/repos/linkedin/gobblin/hooks","issue_events_url":"https://api.github.com/repos/linkedin/gobblin/issues/events{/number}","events_url":"https://api.github.com/repos/linkedin/gobblin/events","assignees_url":"https://api.github.com/repos/linkedin/gobblin/assignees{/user}","branches_url":"https://api.github.com/repos/linkedin/gobblin/branches{/branch}","tags_url":"https://api.github.com/repos/linkedin/gobblin/tags","blobs_url":"https://api.github.com/repos/linkedin/gobblin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linkedin/gobblin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linkedin/gobblin/git/refs{/sha}","trees_url":"https://api.github.com/repos/linkedin/gobblin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linkedin/gobblin/statuses/{sha}","languages_url":"https://api.github.com/repos/linkedin/gobblin/languages","stargazers_url":"https://api.github.com/repos/linkedin/gobblin/stargazers","contributors_url":"https://api.github.com/repos/linkedin/gobblin/contributors","subscribers_url":"https://api.github.com/repos/linkedin/gobblin/subscribers","subscription_url":"https://api.github.com/repos/linkedin/gobblin/subscription","commits_url":"https://api.github.com/repos/linkedin/gobblin/commits{/sha}","git_commits_url":"https://api.github.com/repos/linkedin/gobblin/git/commits{/sha}","comments_url":"https://api.github.com/repos/linkedin/gobblin/comments{/number}","issue_comment_url":"https://api.github.com/repos/linkedin/gobblin/issues/comments{/number}","contents_url":"https://api.github.com/repos/linkedin/gobblin/contents/{+path}","compare_url":"https://api.github.com/repos/linkedin/gobblin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linkedin/gobblin/merges","archive_url":"https://api.github.com/repos/linkedin/gobblin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linkedin/gobblin/downloads","issues_url":"https://api.github.com/repos/linkedin/gobblin/issues{/number}","pulls_url":"https://api.github.com/repos/linkedin/gobblin/pulls{/number}","milestones_url":"https://api.github.com/repos/linkedin/gobblin/milestones{/number}","notifications_url":"https://api.github.com/repos/linkedin/gobblin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linkedin/gobblin/labels{/name}","releases_url":"https://api.github.com/repos/linkedin/gobblin/releases{/id}","created_at":"2014-12-01T18:10:50Z","updated_at":"2015-05-19T06:10:58Z","pushed_at":"2015-05-21T21:44:55Z","git_url":"git://github.com/linkedin/gobblin.git","ssh_url":"git@github.com:linkedin/gobblin.git","clone_url":"https://github.com/linkedin/gobblin.git","svn_url":"https://github.com/linkedin/gobblin","homepage":null,"size":157829,"stargazers_count":38,"watchers_count":38,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":9,"forks":25,"open_issues":9,"watchers":38,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/135"},"html":{"href":"https://github.com/linkedin/gobblin/pull/135"},"issue":{"href":"https://api.github.com/repos/linkedin/gobblin/issues/135"},"comments":{"href":"https://api.github.com/repos/linkedin/gobblin/issues/135/comments"},"review_comments":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/135/comments"},"review_comment":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/135/commits"},"statuses":{"href":"https://api.github.com/repos/linkedin/gobblin/statuses/c80ef7e0b47310b9b0427f28a24d30df3265e38c"}}}}