{"action":"created","comment":{"url":"https://api.github.com/repos/apache/beam/pulls/comments/113065199","pull_request_review_id":34426405,"id":113065199,"diff_hunk":"@@ -0,0 +1,111 @@\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+\n+package org.apache.beam.runners.dataflow.util;\n+\n+import static com.google.common.base.Preconditions.checkNotNull;\n+\n+import com.google.common.collect.ImmutableMap;\n+import com.google.common.collect.Lists;\n+import java.util.ArrayList;\n+import java.util.Collection;\n+import java.util.List;\n+import java.util.Map;\n+import org.apache.beam.sdk.coders.Coder;\n+import org.apache.beam.sdk.coders.CustomCoder;\n+import org.apache.beam.sdk.coders.StandardCoder;\n+import org.apache.beam.sdk.util.CloudObject;\n+import org.apache.beam.sdk.util.PropertyNames;\n+import org.apache.beam.sdk.util.SerializableUtils;\n+import org.apache.beam.sdk.util.StringUtils;\n+import org.apache.beam.sdk.util.Structs;\n+\n+/** Utilities for converting an object to a {@link CloudObject}. */\n+public class CloudObjects {\n+  private CloudObjects() {}\n+\n+  static final Map<Class<? extends Coder>, CloudObjectTranslator<? extends Coder>>\n+      CODER_TRANSLATORS = populateCoderInitializers();\n+\n+  private static Map<Class<? extends Coder>, CloudObjectTranslator<? extends Coder>>\n+      populateCoderInitializers() {\n+    ImmutableMap.Builder<Class<? extends Coder>, CloudObjectTranslator<? extends Coder>> builder =\n+        ImmutableMap.builder();\n+    // TODO: Implement\n+    return builder.build();\n+  }\n+\n+  public static CloudObject asCloudObject(Coder<?> coder) {\n+    if (CODER_TRANSLATORS.containsKey(coder.getClass())) {\n+      // TODO: Make this cast less dangerous\n+      return asCloudObject((StandardCoder<?>) coder);\n+    } else if (coder instanceof CustomCoder) {\n+      return asCloudObject((CustomCoder<?>) coder);\n+    }\n+    throw new IllegalArgumentException(\n+        String.format(\n+            \"Non-Custom %s with no registered %s\", Coder.class, CloudObjectTranslator.class));\n+  }\n+\n+  private static CloudObject asCloudObject(CustomCoder<?> coder) {\n+    CloudObject result = CloudObject.forClass(CustomCoder.class);\n+    Structs.addString(result, \"type\", coder.getClass().getName());\n+    Structs.addString(\n+        result,\n+        \"serialized_coder\",\n+        StringUtils.byteArrayToJsonString(SerializableUtils.serializeToByteArray(coder)));\n+\n+    return result;\n+  }\n+\n+  /**\n+   * Convert the provided {@link StandardCoder} to a {@link CloudObject}.\n+   */\n+  private static CloudObject asCloudObject(StandardCoder<?> coder) {\n+    CloudObject result;\n+    CloudObjectTranslator<StandardCoder<?>> initializer =\n+        (CloudObjectTranslator<StandardCoder<?>>) CODER_TRANSLATORS.get(coder);\n+    if (initializer != null) {","path":"runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/CloudObjects.java","position":83,"original_position":83,"commit_id":"0abe8b3056d50328fd2e64aa6a705904e7054c28","original_commit_id":"0abe8b3056d50328fd2e64aa6a705904e7054c28","user":{"login":"tgroh","id":429866,"avatar_url":"https://avatars1.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"body":"yes. done.","created_at":"2017-04-24T21:48:46Z","updated_at":"2017-04-24T21:49:21Z","html_url":"https://github.com/apache/beam/pull/2642#discussion_r113065199","pull_request_url":"https://api.github.com/repos/apache/beam/pulls/2642","_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/comments/113065199"},"html":{"href":"https://github.com/apache/beam/pull/2642#discussion_r113065199"},"pull_request":{"href":"https://api.github.com/repos/apache/beam/pulls/2642"}}},"pull_request":{"url":"https://api.github.com/repos/apache/beam/pulls/2642","id":117084548,"html_url":"https://github.com/apache/beam/pull/2642","diff_url":"https://github.com/apache/beam/pull/2642.diff","patch_url":"https://github.com/apache/beam/pull/2642.patch","issue_url":"https://api.github.com/repos/apache/beam/issues/2642","number":2642,"state":"open","locked":false,"title":"Add Cloud Object Translators for Coders","user":{"login":"tgroh","id":429866,"avatar_url":"https://avatars1.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"body":"Be sure to do all of the following to help us incorporate your contribution\r\nquickly and easily:\r\n\r\n - [x] Make sure the PR title is formatted like:\r\n   `[BEAM-<Jira issue #>] Description of pull request`\r\n - [x] Make sure tests pass via `mvn clean verify`. (Even better, enable\r\n       Travis-CI on your fork and ensure the whole test matrix passes).\r\n - [x] Replace `<Jira issue #>` in the title with the actual Jira issue\r\n       number, if there is one.\r\n - [x] If this contribution is large, please file an Apache\r\n       [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).\r\n\r\n---\r\nCurrently unused. These will replace the coder.asCloudObject within\r\nDataflow.","created_at":"2017-04-21T23:36:15Z","updated_at":"2017-04-24T21:49:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"16ff26a51efb8d9c1a882698a5d8be70414a2913","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/beam/pulls/2642/commits","review_comments_url":"https://api.github.com/repos/apache/beam/pulls/2642/comments","review_comment_url":"https://api.github.com/repos/apache/beam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/beam/issues/2642/comments","statuses_url":"https://api.github.com/repos/apache/beam/statuses/0abe8b3056d50328fd2e64aa6a705904e7054c28","head":{"label":"tgroh:cloud_objects_in_df","ref":"cloud_objects_in_df","sha":"0abe8b3056d50328fd2e64aa6a705904e7054c28","user":{"login":"tgroh","id":429866,"avatar_url":"https://avatars1.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"repo":{"id":52644388,"name":"beam","full_name":"tgroh/beam","owner":{"login":"tgroh","id":429866,"avatar_url":"https://avatars1.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tgroh/beam","description":"Mirror of Apache Beam","fork":true,"url":"https://api.github.com/repos/tgroh/beam","forks_url":"https://api.github.com/repos/tgroh/beam/forks","keys_url":"https://api.github.com/repos/tgroh/beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tgroh/beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tgroh/beam/teams","hooks_url":"https://api.github.com/repos/tgroh/beam/hooks","issue_events_url":"https://api.github.com/repos/tgroh/beam/issues/events{/number}","events_url":"https://api.github.com/repos/tgroh/beam/events","assignees_url":"https://api.github.com/repos/tgroh/beam/assignees{/user}","branches_url":"https://api.github.com/repos/tgroh/beam/branches{/branch}","tags_url":"https://api.github.com/repos/tgroh/beam/tags","blobs_url":"https://api.github.com/repos/tgroh/beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tgroh/beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tgroh/beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/tgroh/beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tgroh/beam/statuses/{sha}","languages_url":"https://api.github.com/repos/tgroh/beam/languages","stargazers_url":"https://api.github.com/repos/tgroh/beam/stargazers","contributors_url":"https://api.github.com/repos/tgroh/beam/contributors","subscribers_url":"https://api.github.com/repos/tgroh/beam/subscribers","subscription_url":"https://api.github.com/repos/tgroh/beam/subscription","commits_url":"https://api.github.com/repos/tgroh/beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/tgroh/beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/tgroh/beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/tgroh/beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/tgroh/beam/contents/{+path}","compare_url":"https://api.github.com/repos/tgroh/beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tgroh/beam/merges","archive_url":"https://api.github.com/repos/tgroh/beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tgroh/beam/downloads","issues_url":"https://api.github.com/repos/tgroh/beam/issues{/number}","pulls_url":"https://api.github.com/repos/tgroh/beam/pulls{/number}","milestones_url":"https://api.github.com/repos/tgroh/beam/milestones{/number}","notifications_url":"https://api.github.com/repos/tgroh/beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tgroh/beam/labels{/name}","releases_url":"https://api.github.com/repos/tgroh/beam/releases{/id}","deployments_url":"https://api.github.com/repos/tgroh/beam/deployments","created_at":"2016-02-27T01:43:32Z","updated_at":"2017-03-14T22:58:34Z","pushed_at":"2017-04-24T21:30:40Z","git_url":"git://github.com/tgroh/beam.git","ssh_url":"git@github.com:tgroh/beam.git","clone_url":"https://github.com/tgroh/beam.git","svn_url":"https://github.com/tgroh/beam","homepage":"","size":34500,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"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":"7a2fe68fd37bf60b357d9894ba0c365892154bcb","user":{"login":"apache","id":47359,"avatar_url":"https://avatars3.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":"beam","full_name":"apache/beam","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars3.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/beam","description":"Mirror of Apache Beam","fork":false,"url":"https://api.github.com/repos/apache/beam","forks_url":"https://api.github.com/repos/apache/beam/forks","keys_url":"https://api.github.com/repos/apache/beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/beam/teams","hooks_url":"https://api.github.com/repos/apache/beam/hooks","issue_events_url":"https://api.github.com/repos/apache/beam/issues/events{/number}","events_url":"https://api.github.com/repos/apache/beam/events","assignees_url":"https://api.github.com/repos/apache/beam/assignees{/user}","branches_url":"https://api.github.com/repos/apache/beam/branches{/branch}","tags_url":"https://api.github.com/repos/apache/beam/tags","blobs_url":"https://api.github.com/repos/apache/beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/beam/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/beam/languages","stargazers_url":"https://api.github.com/repos/apache/beam/stargazers","contributors_url":"https://api.github.com/repos/apache/beam/contributors","subscribers_url":"https://api.github.com/repos/apache/beam/subscribers","subscription_url":"https://api.github.com/repos/apache/beam/subscription","commits_url":"https://api.github.com/repos/apache/beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/beam/contents/{+path}","compare_url":"https://api.github.com/repos/apache/beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/beam/merges","archive_url":"https://api.github.com/repos/apache/beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/beam/downloads","issues_url":"https://api.github.com/repos/apache/beam/issues{/number}","pulls_url":"https://api.github.com/repos/apache/beam/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/beam/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/beam/labels{/name}","releases_url":"https://api.github.com/repos/apache/beam/releases{/id}","deployments_url":"https://api.github.com/repos/apache/beam/deployments","created_at":"2016-02-02T08:00:06Z","updated_at":"2017-04-23T23:06:08Z","pushed_at":"2017-04-24T21:47:09Z","git_url":"git://github.com/apache/beam.git","ssh_url":"git@github.com:apache/beam.git","clone_url":"https://github.com/apache/beam.git","svn_url":"https://github.com/apache/beam","homepage":"","size":32892,"stargazers_count":1096,"watchers_count":1096,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":596,"mirror_url":"git://git.apache.org/beam.git","open_issues_count":74,"forks":596,"open_issues":74,"watchers":1096,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/2642"},"html":{"href":"https://github.com/apache/beam/pull/2642"},"issue":{"href":"https://api.github.com/repos/apache/beam/issues/2642"},"comments":{"href":"https://api.github.com/repos/apache/beam/issues/2642/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/beam/pulls/2642/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/beam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/beam/pulls/2642/commits"},"statuses":{"href":"https://api.github.com/repos/apache/beam/statuses/0abe8b3056d50328fd2e64aa6a705904e7054c28"}}}}
{"actor":{"display_login":"tgroh"}}