{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/81651649","pull_request_review_id":2616628,"id":81651649,"diff_hunk":"@@ -0,0 +1,412 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  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, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.apache.beam.runners.core;\n+\n+import static com.google.common.base.Preconditions.checkNotNull;\n+\n+import com.google.common.collect.Iterables;\n+import java.util.List;\n+import java.util.UUID;\n+import org.apache.beam.sdk.annotations.Experimental;\n+import org.apache.beam.sdk.coders.Coder;\n+import org.apache.beam.sdk.options.PipelineOptions;\n+import org.apache.beam.sdk.transforms.DoFn;\n+import org.apache.beam.sdk.transforms.OldDoFn;\n+import org.apache.beam.sdk.transforms.PTransform;\n+import org.apache.beam.sdk.transforms.ParDo;\n+import org.apache.beam.sdk.transforms.SerializableFunction;\n+import org.apache.beam.sdk.transforms.WithKeys;\n+import org.apache.beam.sdk.transforms.reflect.DoFnInvoker;\n+import org.apache.beam.sdk.transforms.reflect.DoFnInvokers;\n+import org.apache.beam.sdk.transforms.reflect.DoFnSignatures;\n+import org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker;\n+import org.apache.beam.sdk.transforms.windowing.BoundedWindow;\n+import org.apache.beam.sdk.transforms.windowing.GlobalWindow;\n+import org.apache.beam.sdk.transforms.windowing.OutputTimeFns;\n+import org.apache.beam.sdk.transforms.windowing.PaneInfo;\n+import org.apache.beam.sdk.util.KeyedWorkItem;\n+import org.apache.beam.sdk.util.TimeDomain;\n+import org.apache.beam.sdk.util.TimerInternals;\n+import org.apache.beam.sdk.util.WindowedValue;\n+import org.apache.beam.sdk.util.state.StateNamespace;\n+import org.apache.beam.sdk.util.state.StateNamespaces;\n+import org.apache.beam.sdk.util.state.StateTag;\n+import org.apache.beam.sdk.util.state.StateTags;\n+import org.apache.beam.sdk.util.state.ValueState;\n+import org.apache.beam.sdk.util.state.WatermarkHoldState;\n+import org.apache.beam.sdk.values.PCollection;\n+import org.apache.beam.sdk.values.PCollectionView;\n+import org.apache.beam.sdk.values.TupleTag;\n+import org.joda.time.Instant;\n+\n+/**\n+ * A utility transform that executes a <a\n+ * href=\"https://s.apache.org/splittable-do-fn\">splittable</a> {@link DoFn} by expanding it into a\n+ * network of simpler transforms: pair with restriction, split restrictions, assign unique key and\n+ * group by it (in order to get access to per-key state and timers), then process.\n+ *\n+ * <p>This transform is intended as a helper for internal use by runners when implementing {@code\n+ * ParDo.of(splittable DoFn)}, but not for direct use by pipeline writers.\n+ */\n+@Experimental(Experimental.Kind.SPLITTABLE_DO_FN)\n+public class SplittableParDo<\n+        InputT, OutputT, RestrictionT, TrackerT extends RestrictionTracker<RestrictionT>>\n+    extends PTransform<PCollection<InputT>, PCollection<OutputT>> {\n+  private final DoFn<InputT, OutputT> fn;\n+\n+  /**\n+   * Creates the transform for the given original {@link ParDo} and {@link DoFn}.\n+   *\n+   * @param fn The splittable {@link DoFn} inside the original {@link ParDo} transform.\n+   */\n+  public SplittableParDo(DoFn<InputT, OutputT> fn) {\n+    this.fn = fn;\n+  }\n+\n+  @Override\n+  public PCollection<OutputT> apply(PCollection<InputT> input) {\n+    PCollection.IsBounded isFnBounded =\n+        DoFnSignatures.INSTANCE.getOrParseSignature(fn.getClass()).isBounded();\n+    Coder<RestrictionT> restrictionCoder =\n+        DoFnInvokers.INSTANCE.newByteBuddyInvoker(fn).invokeGetRestrictionCoder();\n+    Coder<ElementRestriction<InputT, RestrictionT>> splitCoder =\n+        ElementRestrictionCoder.of(input.getCoder(), restrictionCoder);\n+\n+    return input\n+        .apply(\n+            \"Pair with initial restriction\",\n+            ParDo.of(new PairWithRestrictionFn<InputT, OutputT, RestrictionT>(fn)))\n+        .setCoder(splitCoder)\n+        .apply(\"Split restriction\", ParDo.of(new SplitRestrictionFn<InputT, RestrictionT>(fn)))\n+        .setCoder(splitCoder)","path":"runners/core-java/src/main/java/org/apache/beam/runners/core/SplittableParDo.java","position":null,"original_position":96,"commit_id":"b3d72a2ccfcef4a32336127e4c6d130f5760580f","original_commit_id":"3544760f12dd293da3eb3c325a9dc8fe5748f531","user":{"login":"jkff","id":343722,"avatar_url":"https://avatars.githubusercontent.com/u/343722?v=3","gravatar_id":"","url":"https://api.github.com/users/jkff","html_url":"https://github.com/jkff","followers_url":"https://api.github.com/users/jkff/followers","following_url":"https://api.github.com/users/jkff/following{/other_user}","gists_url":"https://api.github.com/users/jkff/gists{/gist_id}","starred_url":"https://api.github.com/users/jkff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkff/subscriptions","organizations_url":"https://api.github.com/users/jkff/orgs","repos_url":"https://api.github.com/users/jkff/repos","events_url":"https://api.github.com/users/jkff/events{/privacy}","received_events_url":"https://api.github.com/users/jkff/received_events","type":"User","site_admin":false},"body":"It's necessary for some reason - I didn't dig deeper.","created_at":"2016-10-03T22:15:00Z","updated_at":"2016-10-03T22:15:00Z","html_url":"https://github.com/apache/incubator-beam/pull/896#discussion_r81651649","pull_request_url":"https://api.github.com/repos/apache/incubator-beam/pulls/896","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/81651649"},"html":{"href":"https://github.com/apache/incubator-beam/pull/896#discussion_r81651649"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/896"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/896","id":82974197,"html_url":"https://github.com/apache/incubator-beam/pull/896","diff_url":"https://github.com/apache/incubator-beam/pull/896.diff","patch_url":"https://github.com/apache/incubator-beam/pull/896.patch","issue_url":"https://api.github.com/repos/apache/incubator-beam/issues/896","number":896,"state":"open","locked":false,"title":"[BEAM-65] SplittableDoFn prototype.","user":{"login":"jkff","id":343722,"avatar_url":"https://avatars.githubusercontent.com/u/343722?v=3","gravatar_id":"","url":"https://api.github.com/users/jkff","html_url":"https://github.com/jkff","followers_url":"https://api.github.com/users/jkff/followers","following_url":"https://api.github.com/users/jkff/following{/other_user}","gists_url":"https://api.github.com/users/jkff/gists{/gist_id}","starred_url":"https://api.github.com/users/jkff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkff/subscriptions","organizations_url":"https://api.github.com/users/jkff/orgs","repos_url":"https://api.github.com/users/jkff/repos","events_url":"https://api.github.com/users/jkff/events{/privacy}","received_events_url":"https://api.github.com/users/jkff/received_events","type":"User","site_admin":false},"body":"Work in progress. Currently only runs in direct runner,\r\nand not ready for any use by real users.\r\n\r\nNo tests for most of the code yet (will add later in this PR) but the rest is ready to take a look.","created_at":"2016-08-27T01:53:01Z","updated_at":"2016-10-03T22:15:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3a5c3302b115d6c171262f92588cde916b32e46","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-beam/pulls/896/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-beam/pulls/896/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-beam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-beam/issues/896/comments","statuses_url":"https://api.github.com/repos/apache/incubator-beam/statuses/b3d72a2ccfcef4a32336127e4c6d130f5760580f","head":{"label":"jkff:splittable-do-fn","ref":"splittable-do-fn","sha":"b3d72a2ccfcef4a32336127e4c6d130f5760580f","user":{"login":"jkff","id":343722,"avatar_url":"https://avatars.githubusercontent.com/u/343722?v=3","gravatar_id":"","url":"https://api.github.com/users/jkff","html_url":"https://github.com/jkff","followers_url":"https://api.github.com/users/jkff/followers","following_url":"https://api.github.com/users/jkff/following{/other_user}","gists_url":"https://api.github.com/users/jkff/gists{/gist_id}","starred_url":"https://api.github.com/users/jkff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkff/subscriptions","organizations_url":"https://api.github.com/users/jkff/orgs","repos_url":"https://api.github.com/users/jkff/repos","events_url":"https://api.github.com/users/jkff/events{/privacy}","received_events_url":"https://api.github.com/users/jkff/received_events","type":"User","site_admin":false},"repo":{"id":53902119,"name":"incubator-beam","full_name":"jkff/incubator-beam","owner":{"login":"jkff","id":343722,"avatar_url":"https://avatars.githubusercontent.com/u/343722?v=3","gravatar_id":"","url":"https://api.github.com/users/jkff","html_url":"https://github.com/jkff","followers_url":"https://api.github.com/users/jkff/followers","following_url":"https://api.github.com/users/jkff/following{/other_user}","gists_url":"https://api.github.com/users/jkff/gists{/gist_id}","starred_url":"https://api.github.com/users/jkff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkff/subscriptions","organizations_url":"https://api.github.com/users/jkff/orgs","repos_url":"https://api.github.com/users/jkff/repos","events_url":"https://api.github.com/users/jkff/events{/privacy}","received_events_url":"https://api.github.com/users/jkff/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jkff/incubator-beam","description":"Mirror of Apache Beam (Incubating)","fork":true,"url":"https://api.github.com/repos/jkff/incubator-beam","forks_url":"https://api.github.com/repos/jkff/incubator-beam/forks","keys_url":"https://api.github.com/repos/jkff/incubator-beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jkff/incubator-beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jkff/incubator-beam/teams","hooks_url":"https://api.github.com/repos/jkff/incubator-beam/hooks","issue_events_url":"https://api.github.com/repos/jkff/incubator-beam/issues/events{/number}","events_url":"https://api.github.com/repos/jkff/incubator-beam/events","assignees_url":"https://api.github.com/repos/jkff/incubator-beam/assignees{/user}","branches_url":"https://api.github.com/repos/jkff/incubator-beam/branches{/branch}","tags_url":"https://api.github.com/repos/jkff/incubator-beam/tags","blobs_url":"https://api.github.com/repos/jkff/incubator-beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jkff/incubator-beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jkff/incubator-beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/jkff/incubator-beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jkff/incubator-beam/statuses/{sha}","languages_url":"https://api.github.com/repos/jkff/incubator-beam/languages","stargazers_url":"https://api.github.com/repos/jkff/incubator-beam/stargazers","contributors_url":"https://api.github.com/repos/jkff/incubator-beam/contributors","subscribers_url":"https://api.github.com/repos/jkff/incubator-beam/subscribers","subscription_url":"https://api.github.com/repos/jkff/incubator-beam/subscription","commits_url":"https://api.github.com/repos/jkff/incubator-beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/jkff/incubator-beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/jkff/incubator-beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/jkff/incubator-beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/jkff/incubator-beam/contents/{+path}","compare_url":"https://api.github.com/repos/jkff/incubator-beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jkff/incubator-beam/merges","archive_url":"https://api.github.com/repos/jkff/incubator-beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jkff/incubator-beam/downloads","issues_url":"https://api.github.com/repos/jkff/incubator-beam/issues{/number}","pulls_url":"https://api.github.com/repos/jkff/incubator-beam/pulls{/number}","milestones_url":"https://api.github.com/repos/jkff/incubator-beam/milestones{/number}","notifications_url":"https://api.github.com/repos/jkff/incubator-beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jkff/incubator-beam/labels{/name}","releases_url":"https://api.github.com/repos/jkff/incubator-beam/releases{/id}","deployments_url":"https://api.github.com/repos/jkff/incubator-beam/deployments","created_at":"2016-03-15T00:32:38Z","updated_at":"2016-03-15T00:32:41Z","pushed_at":"2016-10-03T22:14:22Z","git_url":"git://github.com/jkff/incubator-beam.git","ssh_url":"git@github.com:jkff/incubator-beam.git","clone_url":"https://github.com/jkff/incubator-beam.git","svn_url":"https://github.com/jkff/incubator-beam","homepage":null,"size":18067,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"8462acbcbe464ed51898cf0055ced7405e36efde","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","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":50904245,"name":"incubator-beam","full_name":"apache/incubator-beam","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","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},"private":false,"html_url":"https://github.com/apache/incubator-beam","description":"Mirror of Apache Beam (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-beam","forks_url":"https://api.github.com/repos/apache/incubator-beam/forks","keys_url":"https://api.github.com/repos/apache/incubator-beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-beam/teams","hooks_url":"https://api.github.com/repos/apache/incubator-beam/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-beam/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-beam/events","assignees_url":"https://api.github.com/repos/apache/incubator-beam/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-beam/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-beam/tags","blobs_url":"https://api.github.com/repos/apache/incubator-beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-beam/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-beam/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-beam/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-beam/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-beam/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-beam/subscription","commits_url":"https://api.github.com/repos/apache/incubator-beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-beam/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-beam/merges","archive_url":"https://api.github.com/repos/apache/incubator-beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-beam/downloads","issues_url":"https://api.github.com/repos/apache/incubator-beam/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-beam/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-beam/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-beam/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-beam/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-beam/deployments","created_at":"2016-02-02T08:00:06Z","updated_at":"2016-10-02T20:26:55Z","pushed_at":"2016-10-03T22:14:22Z","git_url":"git://github.com/apache/incubator-beam.git","ssh_url":"git@github.com:apache/incubator-beam.git","clone_url":"https://github.com/apache/incubator-beam.git","svn_url":"https://github.com/apache/incubator-beam","homepage":null,"size":29050,"stargazers_count":375,"watchers_count":375,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":237,"mirror_url":"git://git.apache.org/incubator-beam.git","open_issues_count":49,"forks":237,"open_issues":49,"watchers":375,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/896"},"html":{"href":"https://github.com/apache/incubator-beam/pull/896"},"issue":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/896"},"comments":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/896/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/896/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/896/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-beam/statuses/b3d72a2ccfcef4a32336127e4c6d130f5760580f"}}}}
{"actor":{"display_login":"jkff"}}