{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/83915581","pull_request_review_id":4721823,"id":83915581,"diff_hunk":"@@ -146,6 +152,63 @@ def apply(self, pcoll):\n     output_type = typehints.Dict[key_type, value_type]\n     return (pcoll\n             | CreatePCollectionView(\n-                pvalue.DictPCollectionView(pcoll.pipeline))\n+                pvalue.DictPCollectionView(\n+                    pcoll.pipeline,\n+                    default_window_mapping_fn(pcoll.windowing.windowfn)))\n             .with_input_types(input_type)\n             .with_output_types(output_type))\n+\n+\n+# Top-level function so we can identify it later.\n+def _global_window_mapping_fn(w, global_window=window.GlobalWindow()):\n+  return global_window\n+\n+\n+def default_window_mapping_fn(target_window_fn):\n+  if target_window_fn == window.GlobalWindows():\n+    return _global_window_mapping_fn\n+  else:\n+    def map_via_end(source_window):\n+      return list(target_window_fn.assign(\n+          window.WindowFn.AssignContext(source_window.max_timestamp())))[-1]\n+    return map_via_end\n+\n+\n+class SideInputMap(object):\n+  \"\"\"Represents a mapping of windows to side input values.\"\"\"\n+\n+  def __init__(self, view_class, view_options, iterable):\n+    self._window_mapping_fn = view_options.get(\n+        'window_mapping_fn', _global_window_mapping_fn)\n+    self._view_class = view_class\n+    self._view_options = view_options\n+    self._iterable = iterable\n+    self._cache = {}\n+\n+  def __getitem__(self, window):\n+    if window not in self._cache:\n+      target_window = self._window_mapping_fn(window)\n+      self._cache[window] = self._view_class.from_iterable(\n+          _FilteringIterable(self._iterable, target_window), self._view_options)","path":"sdks/python/apache_beam/transforms/sideinputs.py","position":82,"original_position":82,"commit_id":"7f126b98d5211ad1f04f0700ab4b3143547fb3b7","original_commit_id":"7f126b98d5211ad1f04f0700ab4b3143547fb3b7","user":{"login":"charlesccychen","id":1055135,"avatar_url":"https://avatars.githubusercontent.com/u/1055135?v=3","gravatar_id":"","url":"https://api.github.com/users/charlesccychen","html_url":"https://github.com/charlesccychen","followers_url":"https://api.github.com/users/charlesccychen/followers","following_url":"https://api.github.com/users/charlesccychen/following{/other_user}","gists_url":"https://api.github.com/users/charlesccychen/gists{/gist_id}","starred_url":"https://api.github.com/users/charlesccychen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charlesccychen/subscriptions","organizations_url":"https://api.github.com/users/charlesccychen/orgs","repos_url":"https://api.github.com/users/charlesccychen/repos","events_url":"https://api.github.com/users/charlesccychen/events{/privacy}","received_events_url":"https://api.github.com/users/charlesccychen/received_events","type":"User","site_admin":false},"body":"From what I'm reading, performance here is likely to be fairly bad as we currently don't have an in-memory side input cache, so each window could causes a reread through the entire side input file.  (No action needed).","created_at":"2016-10-18T18:08:00Z","updated_at":"2016-10-18T18:15:21Z","html_url":"https://github.com/apache/incubator-beam/pull/1100#discussion_r83915581","pull_request_url":"https://api.github.com/repos/apache/incubator-beam/pulls/1100","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/83915581"},"html":{"href":"https://github.com/apache/incubator-beam/pull/1100#discussion_r83915581"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/1100"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/1100","id":89310056,"html_url":"https://github.com/apache/incubator-beam/pull/1100","diff_url":"https://github.com/apache/incubator-beam/pull/1100.diff","patch_url":"https://github.com/apache/incubator-beam/pull/1100.patch","issue_url":"https://api.github.com/repos/apache/incubator-beam/issues/1100","number":1100,"state":"open","locked":false,"title":"[BEAM-733] Windowed side inputs","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-10-14T01:18:07Z","updated_at":"2016-10-18T18:15:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34eef0c66dd3c079df724dd145f411cdadad1921","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-beam/pulls/1100/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-beam/pulls/1100/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/1100/comments","statuses_url":"https://api.github.com/repos/apache/incubator-beam/statuses/7f126b98d5211ad1f04f0700ab4b3143547fb3b7","head":{"label":"robertwb:windowed-side-inputs","ref":"windowed-side-inputs","sha":"7f126b98d5211ad1f04f0700ab4b3143547fb3b7","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-10-18T00:52:18Z","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":18656,"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":"56ab1a4d59e66eea5482caf53850b134e55e53e8","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-17T09:55:30Z","pushed_at":"2016-10-18T18:10:56Z","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":32301,"stargazers_count":388,"watchers_count":388,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":248,"mirror_url":"git://git.apache.org/incubator-beam.git","open_issues_count":49,"forks":248,"open_issues":49,"watchers":388,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/1100"},"html":{"href":"https://github.com/apache/incubator-beam/pull/1100"},"issue":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/1100"},"comments":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/1100/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/1100/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/1100/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-beam/statuses/7f126b98d5211ad1f04f0700ab4b3143547fb3b7"}}}}
{"actor":{"display_login":"charlesccychen"}}