{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/comments/24602859","id":24602859,"diff_hunk":"@@ -0,0 +1,107 @@\n+/*\n+ * Copyright (C) 2015 Google Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+ * use this file except in compliance with the License. You may obtain a copy of\n+ * 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, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations under\n+ * the License.\n+ */\n+\n+package com.google.cloud.dataflow.sdk.coders;\n+\n+import com.google.protobuf.ExtensionRegistry;\n+import com.google.protobuf.GeneratedMessage.GeneratedExtension;\n+import com.google.protobuf.Message;\n+\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.io.OutputStream;\n+import java.lang.reflect.InvocationTargetException;\n+import java.util.List;\n+\n+/**\n+ * An encoder using Google Protocol Buffers 2 binary format.\n+ * <p>\n+ * To learn more about Protocol Buffers, visit:\n+ * https://developers.google.com/protocol-buffers\n+ * <p>\n+ * To use, specify the {@code Coder} type on a PCollection:\n+ * <pre>\n+ * {@code\n+ * PCollection<MyProtoMessage> records =\n+ *     input.apply(...)\n+ *          .setCoder(Proto2Coder.of(MyProtoMessage.class));\n+ * }\n+ * </pre>\n+ * <p>\n+ * Custom message extensions are also supported, but the coder must be made\n+ * aware of them explicitly:\n+ * <pre>\n+ * {@code\n+ * PCollection<MyProtoMessage> records =\n+ *     input.apply(...)\n+ *          .setCoder(Proto2Coder.of(MyProtoMessage.class)\n+ *              .withExtensions(MyProtoMessage.extension1, MyProtoMessage.extension2));\n+ * }\n+ * </pre>\n+ *\n+ * @param <T> the type of elements handled by this coder, must extend {@code Message}\n+ */\n+public class Proto2Coder<T extends Message> extends StandardCoder<T> {\n+\n+    public static <T extends Message> Proto2Coder<T> of(Class<T> protoMessageClass) {\n+      return new Proto2Coder<>(protoMessageClass);\n+    }\n+\n+    private final Class<T> protoMessageClass;\n+    private final ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();\n+\n+    protected Proto2Coder(Class<T> protoMessageClass) {\n+      this.protoMessageClass = protoMessageClass;\n+    }\n+\n+  /**\n+   * Registers Protocol Buffer message extensions with the coder's extension registry.\n+   *\n+   * @param extensions a variadic list of message extensions the coder uses properly parse messages","path":"sdk/src/main/java/com/google/cloud/dataflow/sdk/coders/Proto2Coder.java","position":73,"original_position":73,"commit_id":"ecc3961977db67a08e73723a9bd7e4676aeaed51","original_commit_id":"ecc3961977db67a08e73723a9bd7e4676aeaed51","user":{"login":"lukecwik","id":10078956,"avatar_url":"https://avatars.githubusercontent.com/u/10078956?v=3","gravatar_id":"","url":"https://api.github.com/users/lukecwik","html_url":"https://github.com/lukecwik","followers_url":"https://api.github.com/users/lukecwik/followers","following_url":"https://api.github.com/users/lukecwik/following{/other_user}","gists_url":"https://api.github.com/users/lukecwik/gists{/gist_id}","starred_url":"https://api.github.com/users/lukecwik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukecwik/subscriptions","organizations_url":"https://api.github.com/users/lukecwik/orgs","repos_url":"https://api.github.com/users/lukecwik/repos","events_url":"https://api.github.com/users/lukecwik/events{/privacy}","received_events_url":"https://api.github.com/users/lukecwik/received_events","type":"User","site_admin":false},"body":"Missing \"to\":\r\nthe coder uses properly parse messages -> the coder uses to properly parse messages","created_at":"2015-02-12T18:10:04Z","updated_at":"2015-02-12T18:10:04Z","html_url":"https://github.com/GoogleCloudPlatform/DataflowJavaSDK/pull/5#discussion_r24602859","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/comments/24602859"},"html":{"href":"https://github.com/GoogleCloudPlatform/DataflowJavaSDK/pull/5#discussion_r24602859"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/5","id":28239507,"html_url":"https://github.com/GoogleCloudPlatform/DataflowJavaSDK/pull/5","diff_url":"https://github.com/GoogleCloudPlatform/DataflowJavaSDK/pull/5.diff","patch_url":"https://github.com/GoogleCloudPlatform/DataflowJavaSDK/pull/5.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/issues/5","number":5,"state":"open","locked":false,"title":"Introduces Proto2Coder.","user":{"login":"perezd","id":20598,"avatar_url":"https://avatars.githubusercontent.com/u/20598?v=3","gravatar_id":"","url":"https://api.github.com/users/perezd","html_url":"https://github.com/perezd","followers_url":"https://api.github.com/users/perezd/followers","following_url":"https://api.github.com/users/perezd/following{/other_user}","gists_url":"https://api.github.com/users/perezd/gists{/gist_id}","starred_url":"https://api.github.com/users/perezd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perezd/subscriptions","organizations_url":"https://api.github.com/users/perezd/orgs","repos_url":"https://api.github.com/users/perezd/repos","events_url":"https://api.github.com/users/perezd/events{/privacy}","received_events_url":"https://api.github.com/users/perezd/received_events","type":"User","site_admin":false},"body":"Introduces proto2 coder support for Cloud Dataflow.","created_at":"2015-01-28T23:18:06Z","updated_at":"2015-02-12T18:10:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"571f3cf0032ce3b58c5586ae8f7ebe69346556c9","assignee":{"login":"davorbonaci","id":8442684,"avatar_url":"https://avatars.githubusercontent.com/u/8442684?v=3","gravatar_id":"","url":"https://api.github.com/users/davorbonaci","html_url":"https://github.com/davorbonaci","followers_url":"https://api.github.com/users/davorbonaci/followers","following_url":"https://api.github.com/users/davorbonaci/following{/other_user}","gists_url":"https://api.github.com/users/davorbonaci/gists{/gist_id}","starred_url":"https://api.github.com/users/davorbonaci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davorbonaci/subscriptions","organizations_url":"https://api.github.com/users/davorbonaci/orgs","repos_url":"https://api.github.com/users/davorbonaci/repos","events_url":"https://api.github.com/users/davorbonaci/events{/privacy}","received_events_url":"https://api.github.com/users/davorbonaci/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/5/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/5/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/comments/{number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/issues/5/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/statuses/ecc3961977db67a08e73723a9bd7e4676aeaed51","head":{"label":"perezd:proto2coder","ref":"proto2coder","sha":"ecc3961977db67a08e73723a9bd7e4676aeaed51","user":{"login":"perezd","id":20598,"avatar_url":"https://avatars.githubusercontent.com/u/20598?v=3","gravatar_id":"","url":"https://api.github.com/users/perezd","html_url":"https://github.com/perezd","followers_url":"https://api.github.com/users/perezd/followers","following_url":"https://api.github.com/users/perezd/following{/other_user}","gists_url":"https://api.github.com/users/perezd/gists{/gist_id}","starred_url":"https://api.github.com/users/perezd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perezd/subscriptions","organizations_url":"https://api.github.com/users/perezd/orgs","repos_url":"https://api.github.com/users/perezd/repos","events_url":"https://api.github.com/users/perezd/events{/privacy}","received_events_url":"https://api.github.com/users/perezd/received_events","type":"User","site_admin":false},"repo":{"id":29988021,"name":"DataflowJavaSDK","full_name":"perezd/DataflowJavaSDK","owner":{"login":"perezd","id":20598,"avatar_url":"https://avatars.githubusercontent.com/u/20598?v=3","gravatar_id":"","url":"https://api.github.com/users/perezd","html_url":"https://github.com/perezd","followers_url":"https://api.github.com/users/perezd/followers","following_url":"https://api.github.com/users/perezd/following{/other_user}","gists_url":"https://api.github.com/users/perezd/gists{/gist_id}","starred_url":"https://api.github.com/users/perezd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perezd/subscriptions","organizations_url":"https://api.github.com/users/perezd/orgs","repos_url":"https://api.github.com/users/perezd/repos","events_url":"https://api.github.com/users/perezd/events{/privacy}","received_events_url":"https://api.github.com/users/perezd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/perezd/DataflowJavaSDK","description":"Dataflow provides a simple, powerful model for building both batch and streaming parallel data processing pipelines.","fork":true,"url":"https://api.github.com/repos/perezd/DataflowJavaSDK","forks_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/forks","keys_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/keys{/key_id}","collaborators_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/teams","hooks_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/hooks","issue_events_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/issues/events{/number}","events_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/events","assignees_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/assignees{/user}","branches_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/branches{/branch}","tags_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/tags","blobs_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/git/refs{/sha}","trees_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/git/trees{/sha}","statuses_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/statuses/{sha}","languages_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/languages","stargazers_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/stargazers","contributors_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/contributors","subscribers_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/subscribers","subscription_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/subscription","commits_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/commits{/sha}","git_commits_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/git/commits{/sha}","comments_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/comments{/number}","issue_comment_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/issues/comments/{number}","contents_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/contents/{+path}","compare_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/compare/{base}...{head}","merges_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/merges","archive_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/downloads","issues_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/issues{/number}","pulls_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/pulls{/number}","milestones_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/milestones{/number}","notifications_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/labels{/name}","releases_url":"https://api.github.com/repos/perezd/DataflowJavaSDK/releases{/id}","created_at":"2015-01-28T21:00:49Z","updated_at":"2015-01-28T21:00:51Z","pushed_at":"2015-02-09T21:20:12Z","git_url":"git://github.com/perezd/DataflowJavaSDK.git","ssh_url":"git@github.com:perezd/DataflowJavaSDK.git","clone_url":"https://github.com/perezd/DataflowJavaSDK.git","svn_url":"https://github.com/perezd/DataflowJavaSDK","homepage":"http://cloud.google.com/dataflow","size":1383,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"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":"GoogleCloudPlatform:master","ref":"master","sha":"cc96bbafed2cba8c4eb7e30097a5c8ee8d25d29f","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":27503425,"name":"DataflowJavaSDK","full_name":"GoogleCloudPlatform/DataflowJavaSDK","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/DataflowJavaSDK","description":"Dataflow provides a simple, powerful model for building both batch and streaming parallel data processing pipelines.","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/issues/comments/{number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/releases{/id}","created_at":"2014-12-03T19:20:21Z","updated_at":"2015-02-11T23:25:20Z","pushed_at":"2015-02-12T00:13:19Z","git_url":"git://github.com/GoogleCloudPlatform/DataflowJavaSDK.git","ssh_url":"git@github.com:GoogleCloudPlatform/DataflowJavaSDK.git","clone_url":"https://github.com/GoogleCloudPlatform/DataflowJavaSDK.git","svn_url":"https://github.com/GoogleCloudPlatform/DataflowJavaSDK","homepage":"http://cloud.google.com/dataflow","size":1986,"stargazers_count":207,"watchers_count":207,"language":"Java","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":2,"forks":36,"open_issues":2,"watchers":207,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/5"},"html":{"href":"https://github.com/GoogleCloudPlatform/DataflowJavaSDK/pull/5"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/issues/5"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/DataflowJavaSDK/statuses/ecc3961977db67a08e73723a9bd7e4676aeaed51"}}}}