{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-nemo/pulls/comments/241645692","pull_request_review_id":184963044,"id":241645692,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MTY0NTY5Mg==","diff_hunk":"@@ -282,69 +277,40 @@ private void triggerTimers(final K key,\n     return timerData;\n   }\n \n-  /**\n-   * State and timer internal.\n-   */\n-  final class StateAndTimerForKey {\n-    private StateInternals stateInternals;\n-    private TimerInternals timerInternals;\n-\n-    /**\n-     * @param stateInternals state internals.\n-     * @param timerInternals timer internals.\n-     */\n-    StateAndTimerForKey(final StateInternals stateInternals,\n-                        final TimerInternals timerInternals) {\n-      this.stateInternals = stateInternals;\n-      this.timerInternals = timerInternals;\n-    }\n-  }\n \n   /**\n    * InMemoryStateInternalsFactory.\n    */\n   final class InMemoryStateInternalsFactory implements StateInternalsFactory<K> {\n-    private final Map<K, StateAndTimerForKey> map;\n+    private final Map<K, StateInternals> map;\n \n-    /**\n-     * @param map initial map.\n-     */\n-    InMemoryStateInternalsFactory(final Map<K, StateAndTimerForKey> map) {\n-      this.map = map;\n+    InMemoryStateInternalsFactory() {\n+      this.map = new HashMap<>();\n     }\n \n     @Override\n     public StateInternals stateInternalsForKey(final K key) {\n-      map.putIfAbsent(key, new StateAndTimerForKey(InMemoryStateInternals.forKey(key), null));\n-      final StateAndTimerForKey stateAndTimerForKey = map.get(key);\n-      if (stateAndTimerForKey.stateInternals == null) {\n-        stateAndTimerForKey.stateInternals = InMemoryStateInternals.forKey(key);\n-      }\n-      return stateAndTimerForKey.stateInternals;\n+      map.computeIfAbsent(key, InMemoryStateInternals::forKey);\n+      return map.get(key);\n     }\n   }\n \n   /**\n-   * InMemoryTimerInternalsFactory.\n+   * InMemoryTimerInternalsFactory that hold all timer data of keys.\n    */\n   final class InMemoryTimerInternalsFactory implements TimerInternalsFactory<K> {\n-    private final Map<K, StateAndTimerForKey> map;\n+    private final Map<K, NemoTimerInternals> timerInternalsMap = new HashMap<>();\n+    private ContextForTimer context;","path":"compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/transform/GroupByKeyAndWindowDoFnTransform.java","position":270,"original_position":270,"commit_id":"50327462e12f60f940ad7421963e13c874659e5d","original_commit_id":"50327462e12f60f940ad7421963e13c874659e5d","user":{"login":"johnyangk","id":4114572,"node_id":"MDQ6VXNlcjQxMTQ1NzI=","avatar_url":"https://avatars1.githubusercontent.com/u/4114572?v=4","gravatar_id":"","url":"https://api.github.com/users/johnyangk","html_url":"https://github.com/johnyangk","followers_url":"https://api.github.com/users/johnyangk/followers","following_url":"https://api.github.com/users/johnyangk/following{/other_user}","gists_url":"https://api.github.com/users/johnyangk/gists{/gist_id}","starred_url":"https://api.github.com/users/johnyangk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnyangk/subscriptions","organizations_url":"https://api.github.com/users/johnyangk/orgs","repos_url":"https://api.github.com/users/johnyangk/repos","events_url":"https://api.github.com/users/johnyangk/events{/privacy}","received_events_url":"https://api.github.com/users/johnyangk/received_events","type":"User","site_admin":false},"body":"I'd make this a field of `GroupByKeyAndWindowDoFnTransform`, as `InMemoryTimerInternalsFactory.context` feels a little awkward. \r\n\r\nAlso add a comment:\r\n// reused across different keys","created_at":"2018-12-14T05:10:09Z","updated_at":"2018-12-14T05:19:59Z","html_url":"https://github.com/apache/incubator-nemo/pull/178#discussion_r241645692","pull_request_url":"https://api.github.com/repos/apache/incubator-nemo/pulls/178","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-nemo/pulls/comments/241645692"},"html":{"href":"https://github.com/apache/incubator-nemo/pull/178#discussion_r241645692"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-nemo/pulls/178"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-nemo/pulls/178","id":238270984,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4MjcwOTg0","html_url":"https://github.com/apache/incubator-nemo/pull/178","diff_url":"https://github.com/apache/incubator-nemo/pull/178.diff","patch_url":"https://github.com/apache/incubator-nemo/pull/178.patch","issue_url":"https://api.github.com/repos/apache/incubator-nemo/issues/178","number":178,"state":"open","locked":false,"title":"[NEMO-317] Optimize triggering logic in GroupByKeyAndWindowDoFnTransform","user":{"login":"taegeonum","id":1371383,"node_id":"MDQ6VXNlcjEzNzEzODM=","avatar_url":"https://avatars3.githubusercontent.com/u/1371383?v=4","gravatar_id":"","url":"https://api.github.com/users/taegeonum","html_url":"https://github.com/taegeonum","followers_url":"https://api.github.com/users/taegeonum/followers","following_url":"https://api.github.com/users/taegeonum/following{/other_user}","gists_url":"https://api.github.com/users/taegeonum/gists{/gist_id}","starred_url":"https://api.github.com/users/taegeonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taegeonum/subscriptions","organizations_url":"https://api.github.com/users/taegeonum/orgs","repos_url":"https://api.github.com/users/taegeonum/repos","events_url":"https://api.github.com/users/taegeonum/events{/privacy}","received_events_url":"https://api.github.com/users/taegeonum/received_events","type":"User","site_admin":false},"body":"JIRA: [NEMO-317: Optimize triggering logic in GroupByKeyAndWindowDoFnTransform](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-317)\r\n\r\n**Major changes:**\r\n- Create `NemoTimerInternals` that adds timer data to the shared data structures of `ContextForTimer`. \r\n- Remove timers from `ContextForTimer` and trigger them, instead of iterating all keys. \r\n","created_at":"2018-12-13T05:41:34Z","updated_at":"2018-12-14T05:19:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb45774c3f73804c9cf505a2996d54f53fa22fea","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-nemo/pulls/178/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-nemo/pulls/178/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-nemo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-nemo/issues/178/comments","statuses_url":"https://api.github.com/repos/apache/incubator-nemo/statuses/50327462e12f60f940ad7421963e13c874659e5d","head":{"label":"taegeonum:Nemo-317","ref":"Nemo-317","sha":"50327462e12f60f940ad7421963e13c874659e5d","user":{"login":"taegeonum","id":1371383,"node_id":"MDQ6VXNlcjEzNzEzODM=","avatar_url":"https://avatars3.githubusercontent.com/u/1371383?v=4","gravatar_id":"","url":"https://api.github.com/users/taegeonum","html_url":"https://github.com/taegeonum","followers_url":"https://api.github.com/users/taegeonum/followers","following_url":"https://api.github.com/users/taegeonum/following{/other_user}","gists_url":"https://api.github.com/users/taegeonum/gists{/gist_id}","starred_url":"https://api.github.com/users/taegeonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taegeonum/subscriptions","organizations_url":"https://api.github.com/users/taegeonum/orgs","repos_url":"https://api.github.com/users/taegeonum/repos","events_url":"https://api.github.com/users/taegeonum/events{/privacy}","received_events_url":"https://api.github.com/users/taegeonum/received_events","type":"User","site_admin":false},"repo":{"id":123749092,"node_id":"MDEwOlJlcG9zaXRvcnkxMjM3NDkwOTI=","name":"incubator-nemo","full_name":"taegeonum/incubator-nemo","private":false,"owner":{"login":"taegeonum","id":1371383,"node_id":"MDQ6VXNlcjEzNzEzODM=","avatar_url":"https://avatars3.githubusercontent.com/u/1371383?v=4","gravatar_id":"","url":"https://api.github.com/users/taegeonum","html_url":"https://github.com/taegeonum","followers_url":"https://api.github.com/users/taegeonum/followers","following_url":"https://api.github.com/users/taegeonum/following{/other_user}","gists_url":"https://api.github.com/users/taegeonum/gists{/gist_id}","starred_url":"https://api.github.com/users/taegeonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taegeonum/subscriptions","organizations_url":"https://api.github.com/users/taegeonum/orgs","repos_url":"https://api.github.com/users/taegeonum/repos","events_url":"https://api.github.com/users/taegeonum/events{/privacy}","received_events_url":"https://api.github.com/users/taegeonum/received_events","type":"User","site_admin":false},"html_url":"https://github.com/taegeonum/incubator-nemo","description":"Apache Nemo Incubating","fork":true,"url":"https://api.github.com/repos/taegeonum/incubator-nemo","forks_url":"https://api.github.com/repos/taegeonum/incubator-nemo/forks","keys_url":"https://api.github.com/repos/taegeonum/incubator-nemo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/taegeonum/incubator-nemo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/taegeonum/incubator-nemo/teams","hooks_url":"https://api.github.com/repos/taegeonum/incubator-nemo/hooks","issue_events_url":"https://api.github.com/repos/taegeonum/incubator-nemo/issues/events{/number}","events_url":"https://api.github.com/repos/taegeonum/incubator-nemo/events","assignees_url":"https://api.github.com/repos/taegeonum/incubator-nemo/assignees{/user}","branches_url":"https://api.github.com/repos/taegeonum/incubator-nemo/branches{/branch}","tags_url":"https://api.github.com/repos/taegeonum/incubator-nemo/tags","blobs_url":"https://api.github.com/repos/taegeonum/incubator-nemo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/taegeonum/incubator-nemo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/taegeonum/incubator-nemo/git/refs{/sha}","trees_url":"https://api.github.com/repos/taegeonum/incubator-nemo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/taegeonum/incubator-nemo/statuses/{sha}","languages_url":"https://api.github.com/repos/taegeonum/incubator-nemo/languages","stargazers_url":"https://api.github.com/repos/taegeonum/incubator-nemo/stargazers","contributors_url":"https://api.github.com/repos/taegeonum/incubator-nemo/contributors","subscribers_url":"https://api.github.com/repos/taegeonum/incubator-nemo/subscribers","subscription_url":"https://api.github.com/repos/taegeonum/incubator-nemo/subscription","commits_url":"https://api.github.com/repos/taegeonum/incubator-nemo/commits{/sha}","git_commits_url":"https://api.github.com/repos/taegeonum/incubator-nemo/git/commits{/sha}","comments_url":"https://api.github.com/repos/taegeonum/incubator-nemo/comments{/number}","issue_comment_url":"https://api.github.com/repos/taegeonum/incubator-nemo/issues/comments{/number}","contents_url":"https://api.github.com/repos/taegeonum/incubator-nemo/contents/{+path}","compare_url":"https://api.github.com/repos/taegeonum/incubator-nemo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/taegeonum/incubator-nemo/merges","archive_url":"https://api.github.com/repos/taegeonum/incubator-nemo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/taegeonum/incubator-nemo/downloads","issues_url":"https://api.github.com/repos/taegeonum/incubator-nemo/issues{/number}","pulls_url":"https://api.github.com/repos/taegeonum/incubator-nemo/pulls{/number}","milestones_url":"https://api.github.com/repos/taegeonum/incubator-nemo/milestones{/number}","notifications_url":"https://api.github.com/repos/taegeonum/incubator-nemo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/taegeonum/incubator-nemo/labels{/name}","releases_url":"https://api.github.com/repos/taegeonum/incubator-nemo/releases{/id}","deployments_url":"https://api.github.com/repos/taegeonum/incubator-nemo/deployments","created_at":"2018-03-04T02:20:01Z","updated_at":"2018-03-04T02:20:03Z","pushed_at":"2018-12-13T07:37:13Z","git_url":"git://github.com/taegeonum/incubator-nemo.git","ssh_url":"git@github.com:taegeonum/incubator-nemo.git","clone_url":"https://github.com/taegeonum/incubator-nemo.git","svn_url":"https://github.com/taegeonum/incubator-nemo","homepage":"https://incubator.apache.org/","size":20821,"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,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"299564e4cdcc9bf6644f6c77ac29dceae82f83ec","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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":123152853,"node_id":"MDEwOlJlcG9zaXRvcnkxMjMxNTI4NTM=","name":"incubator-nemo","full_name":"apache/incubator-nemo","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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},"html_url":"https://github.com/apache/incubator-nemo","description":"Apache Nemo (Incubating) - Data Processing System for Flexible Employment With Different Deployment Characteristics","fork":false,"url":"https://api.github.com/repos/apache/incubator-nemo","forks_url":"https://api.github.com/repos/apache/incubator-nemo/forks","keys_url":"https://api.github.com/repos/apache/incubator-nemo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-nemo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-nemo/teams","hooks_url":"https://api.github.com/repos/apache/incubator-nemo/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-nemo/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-nemo/events","assignees_url":"https://api.github.com/repos/apache/incubator-nemo/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-nemo/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-nemo/tags","blobs_url":"https://api.github.com/repos/apache/incubator-nemo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-nemo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-nemo/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-nemo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-nemo/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-nemo/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-nemo/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-nemo/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-nemo/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-nemo/subscription","commits_url":"https://api.github.com/repos/apache/incubator-nemo/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-nemo/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-nemo/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-nemo/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-nemo/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-nemo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-nemo/merges","archive_url":"https://api.github.com/repos/apache/incubator-nemo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-nemo/downloads","issues_url":"https://api.github.com/repos/apache/incubator-nemo/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-nemo/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-nemo/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-nemo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-nemo/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-nemo/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-nemo/deployments","created_at":"2018-02-27T15:59:11Z","updated_at":"2018-12-11T04:46:37Z","pushed_at":"2018-12-13T07:15:06Z","git_url":"git://github.com/apache/incubator-nemo.git","ssh_url":"git@github.com:apache/incubator-nemo.git","clone_url":"https://github.com/apache/incubator-nemo.git","svn_url":"https://github.com/apache/incubator-nemo","homepage":"https://nemo.apache.org","size":22313,"stargazers_count":36,"watchers_count":36,"language":"Java","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":20,"open_issues":4,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-nemo/pulls/178"},"html":{"href":"https://github.com/apache/incubator-nemo/pull/178"},"issue":{"href":"https://api.github.com/repos/apache/incubator-nemo/issues/178"},"comments":{"href":"https://api.github.com/repos/apache/incubator-nemo/issues/178/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-nemo/pulls/178/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-nemo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-nemo/pulls/178/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-nemo/statuses/50327462e12f60f940ad7421963e13c874659e5d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"johnyangk"}}