{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/68484000","id":68484000,"diff_hunk":"@@ -0,0 +1,115 @@\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.sdk.io.hdfs;\n+\n+import org.apache.beam.sdk.coders.AvroCoder;\n+import org.apache.beam.sdk.coders.Coder;\n+import org.apache.beam.sdk.coders.CoderException;\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+\n+import com.google.common.base.Preconditions;\n+\n+import com.fasterxml.jackson.annotation.JsonCreator;\n+import com.fasterxml.jackson.annotation.JsonProperty;\n+import org.apache.avro.mapred.AvroWrapper;\n+\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.io.OutputStream;\n+import java.util.Collections;\n+import java.util.List;\n+\n+/**\n+ * A {@code AvroWrapperCoder} is a {@link org.apache.beam.sdk.coders.Coder} for a Java class that\n+ * implements {@link org.apache.avro.mapred.AvroWrapper}.\n+ *\n+ * @param <WrapperT> the type of the wrapper\n+ * @param <DatumT> the type of the datum\n+ */\n+public class AvroWrapperCoder<WrapperT extends AvroWrapper<DatumT>, DatumT>\n+    extends StandardCoder<WrapperT> {\n+  private static final long serialVersionUID = 0L;\n+\n+  private final Class<WrapperT> wrapperType;\n+  private final AvroCoder<DatumT> datumCoder;\n+\n+  private AvroWrapperCoder(Class<WrapperT> wrapperType, AvroCoder<DatumT> datumCoder) {\n+    this.wrapperType = wrapperType;\n+    this.datumCoder = datumCoder;\n+  }\n+\n+  /**\n+   * Return a {@code AvroWrapperCoder} instance for the provided element class.\n+   * @param <WrapperT> the type of the wrapper\n+   * @param <DatumT> the type of the datum\n+   */\n+  public static <WrapperT extends AvroWrapper<DatumT>, DatumT>\n+  AvroWrapperCoder<WrapperT, DatumT>of(Class<WrapperT> wrapperType, AvroCoder<DatumT> datumCoder) {\n+    return new AvroWrapperCoder<>(wrapperType, datumCoder);\n+  }\n+\n+  @JsonCreator\n+  @SuppressWarnings(\"unchecked\")\n+  public static AvroWrapperCoder<?, ?> of(\n+          @JsonProperty(\"wrapperType\") String wrapperType,\n+          @JsonProperty(PropertyNames.COMPONENT_ENCODINGS) List<Coder<?>> components)\n+          throws ClassNotFoundException {\n+    Class<?> clazz = Class.forName(wrapperType);\n+    if (!AvroWrapper.class.isAssignableFrom(clazz)) {\n+      throw new ClassNotFoundException(\n+              \"Class \" + wrapperType + \" does not implement AvroWrapper\");\n+    }\n+    Preconditions.checkArgument(components.size() == 1,\n+            \"Expecting 1 component, got \" + components.size());\n+    return of((Class<? extends AvroWrapper>) clazz, (AvroCoder<?>) components.get(0));\n+  }\n+\n+  @Override\n+  public void encode(WrapperT value, OutputStream outStream, Context context) throws IOException {\n+    datumCoder.encode(value.datum(), outStream, context);\n+  }\n+\n+  @Override\n+  public WrapperT decode(InputStream inStream, Context context) throws IOException {\n+    try {\n+      WrapperT wrapper = wrapperType.newInstance();\n+      wrapper.datum(datumCoder.decode(inStream, context));\n+      return wrapper;\n+    } catch (InstantiationException | IllegalAccessException e) {\n+      throw new CoderException(\"unable to deserialize record\", e);\n+    }\n+  }\n+\n+  @Override\n+  public List<? extends Coder<?>> getCoderArguments() {\n+    return Collections.singletonList(datumCoder);\n+  }\n+\n+  @Override\n+  public CloudObject asCloudObject() {\n+    CloudObject result = super.asCloudObject();\n+    result.put(\"wrapperType\", wrapperType.getName());\n+    return result;\n+  }\n+\n+  @Override\n+  public void verifyDeterministic() throws NonDeterministicException {}","path":"sdks/java/io/hdfs/src/main/java/org/apache/beam/sdk/io/hdfs/AvroWrapperCoder.java","position":113,"original_position":113,"commit_id":"036ed67941a11de17c51d38e736aee5425dbe637","original_commit_id":"036ed67941a11de17c51d38e736aee5425dbe637","user":{"login":"dhalperi","id":526415,"avatar_url":"https://avatars.githubusercontent.com/u/526415?v=3","gravatar_id":"","url":"https://api.github.com/users/dhalperi","html_url":"https://github.com/dhalperi","followers_url":"https://api.github.com/users/dhalperi/followers","following_url":"https://api.github.com/users/dhalperi/following{/other_user}","gists_url":"https://api.github.com/users/dhalperi/gists{/gist_id}","starred_url":"https://api.github.com/users/dhalperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhalperi/subscriptions","organizations_url":"https://api.github.com/users/dhalperi/orgs","repos_url":"https://api.github.com/users/dhalperi/repos","events_url":"https://api.github.com/users/dhalperi/events{/privacy}","received_events_url":"https://api.github.com/users/dhalperi/received_events","type":"User","site_admin":false},"body":"I'm surprised that this has no implementation. In general, we had to jump through some hoops to get a good AvroCoder that could verify determinism for classes. See [AvroDeterminismChecker](https://github.com/apache/incubator-beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/AvroCoder.java#L362).\r\n\r\nAre these classes really always able to be deterministically coded?","created_at":"2016-06-25T04:43:16Z","updated_at":"2016-06-25T04:43:16Z","html_url":"https://github.com/apache/incubator-beam/pull/485#discussion_r68484000","pull_request_url":"https://api.github.com/repos/apache/incubator-beam/pulls/485","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/68484000"},"html":{"href":"https://github.com/apache/incubator-beam/pull/485#discussion_r68484000"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/485"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/485","id":74280730,"html_url":"https://github.com/apache/incubator-beam/pull/485","diff_url":"https://github.com/apache/incubator-beam/pull/485.diff","patch_url":"https://github.com/apache/incubator-beam/pull/485.patch","issue_url":"https://api.github.com/repos/apache/incubator-beam/issues/485","number":485,"state":"open","locked":false,"title":"[BEAM-371] Backport HDFS enhancements","user":{"login":"nevillelyh","id":468514,"avatar_url":"https://avatars.githubusercontent.com/u/468514?v=3","gravatar_id":"","url":"https://api.github.com/users/nevillelyh","html_url":"https://github.com/nevillelyh","followers_url":"https://api.github.com/users/nevillelyh/followers","following_url":"https://api.github.com/users/nevillelyh/following{/other_user}","gists_url":"https://api.github.com/users/nevillelyh/gists{/gist_id}","starred_url":"https://api.github.com/users/nevillelyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nevillelyh/subscriptions","organizations_url":"https://api.github.com/users/nevillelyh/orgs","repos_url":"https://api.github.com/users/nevillelyh/repos","events_url":"https://api.github.com/users/nevillelyh/events{/privacy}","received_events_url":"https://api.github.com/users/nevillelyh/received_events","type":"User","site_admin":false},"body":"Backport of GoogleCloudPlatform/DataflowJavaSDK#103","created_at":"2016-06-17T17:53:27Z","updated_at":"2016-06-25T04:43:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2dcdee2bbadd63af0b4f2e112c7bddd197e4a35f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-beam/pulls/485/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-beam/pulls/485/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/485/comments","statuses_url":"https://api.github.com/repos/apache/incubator-beam/statuses/036ed67941a11de17c51d38e736aee5425dbe637","head":{"label":"nevillelyh:neville/hdfs","ref":"neville/hdfs","sha":"036ed67941a11de17c51d38e736aee5425dbe637","user":{"login":"nevillelyh","id":468514,"avatar_url":"https://avatars.githubusercontent.com/u/468514?v=3","gravatar_id":"","url":"https://api.github.com/users/nevillelyh","html_url":"https://github.com/nevillelyh","followers_url":"https://api.github.com/users/nevillelyh/followers","following_url":"https://api.github.com/users/nevillelyh/following{/other_user}","gists_url":"https://api.github.com/users/nevillelyh/gists{/gist_id}","starred_url":"https://api.github.com/users/nevillelyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nevillelyh/subscriptions","organizations_url":"https://api.github.com/users/nevillelyh/orgs","repos_url":"https://api.github.com/users/nevillelyh/repos","events_url":"https://api.github.com/users/nevillelyh/events{/privacy}","received_events_url":"https://api.github.com/users/nevillelyh/received_events","type":"User","site_admin":false},"repo":{"id":61322724,"name":"incubator-beam","full_name":"nevillelyh/incubator-beam","owner":{"login":"nevillelyh","id":468514,"avatar_url":"https://avatars.githubusercontent.com/u/468514?v=3","gravatar_id":"","url":"https://api.github.com/users/nevillelyh","html_url":"https://github.com/nevillelyh","followers_url":"https://api.github.com/users/nevillelyh/followers","following_url":"https://api.github.com/users/nevillelyh/following{/other_user}","gists_url":"https://api.github.com/users/nevillelyh/gists{/gist_id}","starred_url":"https://api.github.com/users/nevillelyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nevillelyh/subscriptions","organizations_url":"https://api.github.com/users/nevillelyh/orgs","repos_url":"https://api.github.com/users/nevillelyh/repos","events_url":"https://api.github.com/users/nevillelyh/events{/privacy}","received_events_url":"https://api.github.com/users/nevillelyh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nevillelyh/incubator-beam","description":"Mirror of Apache Beam (Incubating)","fork":true,"url":"https://api.github.com/repos/nevillelyh/incubator-beam","forks_url":"https://api.github.com/repos/nevillelyh/incubator-beam/forks","keys_url":"https://api.github.com/repos/nevillelyh/incubator-beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nevillelyh/incubator-beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nevillelyh/incubator-beam/teams","hooks_url":"https://api.github.com/repos/nevillelyh/incubator-beam/hooks","issue_events_url":"https://api.github.com/repos/nevillelyh/incubator-beam/issues/events{/number}","events_url":"https://api.github.com/repos/nevillelyh/incubator-beam/events","assignees_url":"https://api.github.com/repos/nevillelyh/incubator-beam/assignees{/user}","branches_url":"https://api.github.com/repos/nevillelyh/incubator-beam/branches{/branch}","tags_url":"https://api.github.com/repos/nevillelyh/incubator-beam/tags","blobs_url":"https://api.github.com/repos/nevillelyh/incubator-beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nevillelyh/incubator-beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nevillelyh/incubator-beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/nevillelyh/incubator-beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nevillelyh/incubator-beam/statuses/{sha}","languages_url":"https://api.github.com/repos/nevillelyh/incubator-beam/languages","stargazers_url":"https://api.github.com/repos/nevillelyh/incubator-beam/stargazers","contributors_url":"https://api.github.com/repos/nevillelyh/incubator-beam/contributors","subscribers_url":"https://api.github.com/repos/nevillelyh/incubator-beam/subscribers","subscription_url":"https://api.github.com/repos/nevillelyh/incubator-beam/subscription","commits_url":"https://api.github.com/repos/nevillelyh/incubator-beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/nevillelyh/incubator-beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/nevillelyh/incubator-beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/nevillelyh/incubator-beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/nevillelyh/incubator-beam/contents/{+path}","compare_url":"https://api.github.com/repos/nevillelyh/incubator-beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nevillelyh/incubator-beam/merges","archive_url":"https://api.github.com/repos/nevillelyh/incubator-beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nevillelyh/incubator-beam/downloads","issues_url":"https://api.github.com/repos/nevillelyh/incubator-beam/issues{/number}","pulls_url":"https://api.github.com/repos/nevillelyh/incubator-beam/pulls{/number}","milestones_url":"https://api.github.com/repos/nevillelyh/incubator-beam/milestones{/number}","notifications_url":"https://api.github.com/repos/nevillelyh/incubator-beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nevillelyh/incubator-beam/labels{/name}","releases_url":"https://api.github.com/repos/nevillelyh/incubator-beam/releases{/id}","deployments_url":"https://api.github.com/repos/nevillelyh/incubator-beam/deployments","created_at":"2016-06-16T20:11:44Z","updated_at":"2016-06-17T03:47:42Z","pushed_at":"2016-06-24T19:28:12Z","git_url":"git://github.com/nevillelyh/incubator-beam.git","ssh_url":"git@github.com:nevillelyh/incubator-beam.git","clone_url":"https://github.com/nevillelyh/incubator-beam.git","svn_url":"https://github.com/nevillelyh/incubator-beam","homepage":null,"size":16378,"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":"c83e5c48f002003f60e06a3dd41c83aa2a702a9a","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-06-24T19:54:15Z","pushed_at":"2016-06-25T02:21:08Z","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":22927,"stargazers_count":231,"watchers_count":231,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":134,"mirror_url":"git://git.apache.org/incubator-beam.git","open_issues_count":33,"forks":134,"open_issues":33,"watchers":231,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/485"},"html":{"href":"https://github.com/apache/incubator-beam/pull/485"},"issue":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/485"},"comments":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/485/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/485/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/485/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-beam/statuses/036ed67941a11de17c51d38e736aee5425dbe637"}}}}
{"actor":{"display_login":"dhalperi"}}