{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/80374227","id":80374227,"diff_hunk":"@@ -243,3 +245,98 @@ def read_records(self, file_name, range_tracker):\n                                                 sync_marker)\n         for record in block.records():\n           yield record\n+\n+\n+_avro_codecs = {\n+    fileio.CompressionTypes.UNCOMPRESSED: 'null',\n+    fileio.CompressionTypes.ZLIB: 'deflate',\n+    # fileio.CompressionTypes.SNAPPY: 'snappy',\n+}\n+\n+\n+class WriteToAvro(beam.transforms.PTransform):\n+  \"\"\"A ``PTransform`` for writing avro files.\"\"\"\n+\n+  def __init__(self,\n+               file_path_prefix,\n+               schema,\n+               file_name_suffix='',\n+               num_shards=0,\n+               shard_name_template=None,\n+               mime_type='application/x-avro',\n+               compression_type=fileio.CompressionTypes.ZLIB):\n+    \"\"\"Initialize a WriteToAvro transform.\n+\n+    Args:\n+      file_path_prefix: The file path to write to. The files written will begin\n+        with this prefix, followed by a shard identifier (see num_shards), and\n+        end in a common extension, if given by file_name_suffix. In most cases,\n+        only this argument is specified and num_shards, shard_name_template, and\n+        file_name_suffix use default values.\n+      schema: The schema to use, as returned by avro.schema.parse\n+      file_name_suffix: Suffix for the files written.\n+      append_trailing_newlines: indicate whether this sink should write an\n+        additional newline char after writing each element.\n+      num_shards: The number of files (shards) used for output. If not set, the\n+        service will decide on the optimal number of shards.\n+        Constraining the number of shards is likely to reduce\n+        the performance of a pipeline.  Setting this value is not recommended\n+        unless you require a specific number of output files.\n+      shard_name_template: A template string containing placeholders for\n+        the shard number and shard count. Currently only '' and\n+        '-SSSSS-of-NNNNN' are patterns accepted by the service.\n+        When constructing a filename for a particular shard number, the\n+        upper-case letters 'S' and 'N' are replaced with the 0-padded shard\n+        number and shard count respectively.  This argument can be '' in which\n+        case it behaves as if num_shards was set to 1 and only one file will be\n+        generated. The default pattern used is '-SSSSS-of-NNNNN'.\n+      mime_type: The MIME type to use for the produced files, if the filesystem\n+        supports specifying MIME types.\n+      compression_type: Used to handle compressed output files. Defaults to\n+        CompressionTypes.ZLIB\n+\n+    Returns:\n+      A WriteToAvro transform usable for writing.\n+    \"\"\"\n+    if compression_type not in _avro_codecs:\n+      raise ValueError(\n+          'Compression type %s not supported by avro.' % compression_type)\n+    self.args = (file_path_prefix, schema, file_name_suffix, num_shards,\n+                 shard_name_template, mime_type, compression_type)\n+\n+  def apply(self, pcoll):\n+    # pylint: disable=expression-not-assigned\n+    pcoll | beam.io.iobase.Write(_AvroSink(*self.args))\n+\n+\n+class _AvroSink(fileio.FileSink):\n+  \"\"\"A sink to avro files.\"\"\"\n+\n+  def __init__(self,\n+               file_path_prefix,\n+               schema,\n+               file_name_suffix,\n+               num_shards,\n+               shard_name_template,\n+               mime_type,\n+               compression_type):\n+    super(_AvroSink, self).__init__(\n+        file_path_prefix,\n+        file_name_suffix=file_name_suffix,\n+        num_shards=num_shards,\n+        shard_name_template=shard_name_template,\n+        coder=None,","path":"sdks/python/apache_beam/io/avroio.py","position":121,"original_position":121,"commit_id":"ff6baf8d97964b72a6e8025aba526204fc0f0b94","original_commit_id":"ff6baf8d97964b72a6e8025aba526204fc0f0b94","user":{"login":"chamikaramj","id":10819857,"avatar_url":"https://avatars.githubusercontent.com/u/10819857?v=3","gravatar_id":"","url":"https://api.github.com/users/chamikaramj","html_url":"https://github.com/chamikaramj","followers_url":"https://api.github.com/users/chamikaramj/followers","following_url":"https://api.github.com/users/chamikaramj/following{/other_user}","gists_url":"https://api.github.com/users/chamikaramj/gists{/gist_id}","starred_url":"https://api.github.com/users/chamikaramj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chamikaramj/subscriptions","organizations_url":"https://api.github.com/users/chamikaramj/orgs","repos_url":"https://api.github.com/users/chamikaramj/repos","events_url":"https://api.github.com/users/chamikaramj/events{/privacy}","received_events_url":"https://api.github.com/users/chamikaramj/received_events","type":"User","site_admin":false},"body":"Delete coder here since it's unused.","created_at":"2016-09-25T05:13:49Z","updated_at":"2016-09-25T05:16:38Z","html_url":"https://github.com/apache/incubator-beam/pull/1000#discussion_r80374227","pull_request_url":"https://api.github.com/repos/apache/incubator-beam/pulls/1000","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/80374227"},"html":{"href":"https://github.com/apache/incubator-beam/pull/1000#discussion_r80374227"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/1000"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/1000","id":86638794,"html_url":"https://github.com/apache/incubator-beam/pull/1000","diff_url":"https://github.com/apache/incubator-beam/pull/1000.diff","patch_url":"https://github.com/apache/incubator-beam/pull/1000.patch","issue_url":"https://api.github.com/repos/apache/incubator-beam/issues/1000","number":1000,"state":"open","locked":false,"title":"Avro sinks","user":{"login":"robertwb","id":486017,"avatar_url":"https://avatars.githubusercontent.com/u/486017?v=3","gravatar_id":"","url":"https://api.github.com/users/robertwb","html_url":"https://github.com/robertwb","followers_url":"https://api.github.com/users/robertwb/followers","following_url":"https://api.github.com/users/robertwb/following{/other_user}","gists_url":"https://api.github.com/users/robertwb/gists{/gist_id}","starred_url":"https://api.github.com/users/robertwb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertwb/subscriptions","organizations_url":"https://api.github.com/users/robertwb/orgs","repos_url":"https://api.github.com/users/robertwb/repos","events_url":"https://api.github.com/users/robertwb/events{/privacy}","received_events_url":"https://api.github.com/users/robertwb/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 - [ ] Make sure the PR title is formatted like:\r\n   `[BEAM-<Jira issue #>] Description of pull request`\r\n - [ ] 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 - [ ] Replace `<Jira issue #>` in the title with the actual Jira issue\r\n       number, if there is one.\r\n - [ ] If this contribution is large, please file an Apache\r\n       [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.txt).\r\n\r\n---\r\n","created_at":"2016-09-25T03:59:31Z","updated_at":"2016-09-25T05:16:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64056ee65979284085a47a84c8021558ad102e7c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-beam/pulls/1000/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-beam/pulls/1000/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/1000/comments","statuses_url":"https://api.github.com/repos/apache/incubator-beam/statuses/ff6baf8d97964b72a6e8025aba526204fc0f0b94","head":{"label":"robertwb:avro-sink-only","ref":"avro-sink-only","sha":"ff6baf8d97964b72a6e8025aba526204fc0f0b94","user":{"login":"robertwb","id":486017,"avatar_url":"https://avatars.githubusercontent.com/u/486017?v=3","gravatar_id":"","url":"https://api.github.com/users/robertwb","html_url":"https://github.com/robertwb","followers_url":"https://api.github.com/users/robertwb/followers","following_url":"https://api.github.com/users/robertwb/following{/other_user}","gists_url":"https://api.github.com/users/robertwb/gists{/gist_id}","starred_url":"https://api.github.com/users/robertwb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertwb/subscriptions","organizations_url":"https://api.github.com/users/robertwb/orgs","repos_url":"https://api.github.com/users/robertwb/repos","events_url":"https://api.github.com/users/robertwb/events{/privacy}","received_events_url":"https://api.github.com/users/robertwb/received_events","type":"User","site_admin":false},"repo":{"id":54749372,"name":"incubator-beam","full_name":"robertwb/incubator-beam","owner":{"login":"robertwb","id":486017,"avatar_url":"https://avatars.githubusercontent.com/u/486017?v=3","gravatar_id":"","url":"https://api.github.com/users/robertwb","html_url":"https://github.com/robertwb","followers_url":"https://api.github.com/users/robertwb/followers","following_url":"https://api.github.com/users/robertwb/following{/other_user}","gists_url":"https://api.github.com/users/robertwb/gists{/gist_id}","starred_url":"https://api.github.com/users/robertwb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertwb/subscriptions","organizations_url":"https://api.github.com/users/robertwb/orgs","repos_url":"https://api.github.com/users/robertwb/repos","events_url":"https://api.github.com/users/robertwb/events{/privacy}","received_events_url":"https://api.github.com/users/robertwb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/robertwb/incubator-beam","description":"Mirror of Apache Beam (Incubating)","fork":true,"url":"https://api.github.com/repos/robertwb/incubator-beam","forks_url":"https://api.github.com/repos/robertwb/incubator-beam/forks","keys_url":"https://api.github.com/repos/robertwb/incubator-beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/robertwb/incubator-beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/robertwb/incubator-beam/teams","hooks_url":"https://api.github.com/repos/robertwb/incubator-beam/hooks","issue_events_url":"https://api.github.com/repos/robertwb/incubator-beam/issues/events{/number}","events_url":"https://api.github.com/repos/robertwb/incubator-beam/events","assignees_url":"https://api.github.com/repos/robertwb/incubator-beam/assignees{/user}","branches_url":"https://api.github.com/repos/robertwb/incubator-beam/branches{/branch}","tags_url":"https://api.github.com/repos/robertwb/incubator-beam/tags","blobs_url":"https://api.github.com/repos/robertwb/incubator-beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/robertwb/incubator-beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/robertwb/incubator-beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/robertwb/incubator-beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/robertwb/incubator-beam/statuses/{sha}","languages_url":"https://api.github.com/repos/robertwb/incubator-beam/languages","stargazers_url":"https://api.github.com/repos/robertwb/incubator-beam/stargazers","contributors_url":"https://api.github.com/repos/robertwb/incubator-beam/contributors","subscribers_url":"https://api.github.com/repos/robertwb/incubator-beam/subscribers","subscription_url":"https://api.github.com/repos/robertwb/incubator-beam/subscription","commits_url":"https://api.github.com/repos/robertwb/incubator-beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/robertwb/incubator-beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/robertwb/incubator-beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/robertwb/incubator-beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/robertwb/incubator-beam/contents/{+path}","compare_url":"https://api.github.com/repos/robertwb/incubator-beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/robertwb/incubator-beam/merges","archive_url":"https://api.github.com/repos/robertwb/incubator-beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/robertwb/incubator-beam/downloads","issues_url":"https://api.github.com/repos/robertwb/incubator-beam/issues{/number}","pulls_url":"https://api.github.com/repos/robertwb/incubator-beam/pulls{/number}","milestones_url":"https://api.github.com/repos/robertwb/incubator-beam/milestones{/number}","notifications_url":"https://api.github.com/repos/robertwb/incubator-beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/robertwb/incubator-beam/labels{/name}","releases_url":"https://api.github.com/repos/robertwb/incubator-beam/releases{/id}","deployments_url":"https://api.github.com/repos/robertwb/incubator-beam/deployments","created_at":"2016-03-25T21:47:36Z","updated_at":"2016-03-25T21:47:39Z","pushed_at":"2016-09-25T04:17:37Z","git_url":"git://github.com/robertwb/incubator-beam.git","ssh_url":"git@github.com:robertwb/incubator-beam.git","clone_url":"https://github.com/robertwb/incubator-beam.git","svn_url":"https://github.com/robertwb/incubator-beam","homepage":null,"size":17999,"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:python-sdk","ref":"python-sdk","sha":"753cc9c2e432beb4175902b28b3f9f788bc87f14","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-09-24T16:53:58Z","pushed_at":"2016-09-25T04:17:38Z","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":28532,"stargazers_count":365,"watchers_count":365,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":222,"mirror_url":"git://git.apache.org/incubator-beam.git","open_issues_count":49,"forks":222,"open_issues":49,"watchers":365,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/1000"},"html":{"href":"https://github.com/apache/incubator-beam/pull/1000"},"issue":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/1000"},"comments":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/1000/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/1000/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/1000/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-beam/statuses/ff6baf8d97964b72a6e8025aba526204fc0f0b94"}}}}
{"actor":{"display_login":"chamikaramj"}}