GitHub PullRequestEvent at 2014-08-01 01:23:54
Repository: incubator-flink
Actor: asfgit
Payload: {"action":"closed","number":84,"pull_request":{"url":"https://api.github.com/repos/apache/incubator-flink/pulls/84","id":19035578,"html_url":"https://github.com/apache/incubator-flink/pull/84","diff_url":"https://github.com/apache/incubator-flink/pull/84.diff","patch_url":"https://github.com/apache/incubator-flink/pull/84.patch","issue_url":"https://api.github.com/repos/apache/incubator-flink/issues/84","number":84,"state":"closed","title":"[FLINK-1023] Switch group-at-a-time functions to Iterable (from Iterator)","user":{"login":"StephanEwen","id":1727146,"avatar_url":"https://avatars.githubusercontent.com/u/1727146?v=1","gravatar_id":"8ebc798d33195e7ac63c81f25c1eb865","url":"https://api.github.com/users/StephanEwen","html_url":"https://github.com/StephanEwen","followers_url":"https://api.github.com/users/StephanEwen/followers","following_url":"https://api.github.com/users/StephanEwen/following{/other_user}","gists_url":"https://api.github.com/users/StephanEwen/gists{/gist_id}","starred_url":"https://api.github.com/users/StephanEwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephanEwen/subscriptions","organizations_url":"https://api.github.com/users/StephanEwen/orgs","repos_url":"https://api.github.com/users/StephanEwen/repos","events_url":"https://api.github.com/users/StephanEwen/events{/privacy}","received_events_url":"https://api.github.com/users/StephanEwen/received_events","type":"User","site_admin":false},"body":"This patch allows the *GroupReduce* and the *CoGroup* to use the beautiful *foreach* loop syntax.\r\n\r\n```java\r\npublic void reduce(Iterable<Long> values, Collector<Long> out)\r\n    long sum = 0L;\r\n    \r\n    for (Long num : values) {\r\n        sum += num;\r\n    }\r\n}\r\n```\r\n\r\nSince the data behind the iterable is transient, you cannot iterate over it multiple times. The next time you request an iterator, it will pick up where the previous left off, potentially returning an empty iterator:\r\n\r\n```java\r\npublic void reduce(Iterable<Long> values, Collector<Long> out)\r\n    for (Long num : values) {\r\n        // do something\r\n    }\r\n\r\n    for (Long num : values) {\r\n        // empty loop, will never be entered\r\n    }\r\n}\r\n```\r\n\r\nSome functions need iterator behavior, which can still be used \r\n```java\r\npublic void coGroup(Iterable<Long> values1, Iterable<Long> values2, Collector<Long> out)\r\n    if (values2.iterator().hasNext()) {\r\n        // do something\r\n    }\r\n}\r\n\r\npublic void coGroup(Iterable<Long> values1, Iterable<Long> values2, Collector<Long> out)\r\n    Iterator<Long> iter = values2.iterator();\r\n    if (values2.iterator().hasNext()) {\r\n        do {\r\n            // something\r\n        } while (iter.hasNext());\r\n    }\r\n}\r\n```\r\n\r\n----\r\n\r\nNote:\r\n\r\nThe *Iterable* and the *Iterator* are currently strictly in sync. That means one can pick up where the other left and vice versa. While I would not encourage it to use this pattern, you can actually mix then and do something like the following (which is equivalent to the first example):\r\n```java\r\npublic void reduce(Iterable<Long> values, Collector<Long> out)\r\n    Long sum = values.iterator().next();\r\n    \r\n    for (Long num : values) {\r\n        sum += num;\r\n    }\r\n}\r\n```","created_at":"2014-07-29T15:51:58Z","updated_at":"2014-08-01T01:23:53Z","closed_at":"2014-08-01T01:23:53Z","merged_at":null,"merge_commit_sha":"0ff121cb8658650974e86789ac75a301345988de","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-flink/pulls/84/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-flink/pulls/84/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-flink/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/incubator-flink/issues/84/comments","statuses_url":"https://api.github.com/repos/apache/incubator-flink/statuses/9ccf913fbe89d1b3fad0f8cf1bf6eaa1f2284125","head":{"label":"StephanEwen:iterable","ref":"iterable","sha":"9ccf913fbe89d1b3fad0f8cf1bf6eaa1f2284125","user":{"login":"StephanEwen","id":1727146,"avatar_url":"https://avatars.githubusercontent.com/u/1727146?v=1","gravatar_id":"8ebc798d33195e7ac63c81f25c1eb865","url":"https://api.github.com/users/StephanEwen","html_url":"https://github.com/StephanEwen","followers_url":"https://api.github.com/users/StephanEwen/followers","following_url":"https://api.github.com/users/StephanEwen/following{/other_user}","gists_url":"https://api.github.com/users/StephanEwen/gists{/gist_id}","starred_url":"https://api.github.com/users/StephanEwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephanEwen/subscriptions","organizations_url":"https://api.github.com/users/StephanEwen/orgs","repos_url":"https://api.github.com/users/StephanEwen/repos","events_url":"https://api.github.com/users/StephanEwen/events{/privacy}","received_events_url":"https://api.github.com/users/StephanEwen/received_events","type":"User","site_admin":false},"repo":{"id":21171031,"name":"incubator-flink","full_name":"StephanEwen/incubator-flink","owner":{"login":"StephanEwen","id":1727146,"avatar_url":"https://avatars.githubusercontent.com/u/1727146?v=1","gravatar_id":"8ebc798d33195e7ac63c81f25c1eb865","url":"https://api.github.com/users/StephanEwen","html_url":"https://github.com/StephanEwen","followers_url":"https://api.github.com/users/StephanEwen/followers","following_url":"https://api.github.com/users/StephanEwen/following{/other_user}","gists_url":"https://api.github.com/users/StephanEwen/gists{/gist_id}","starred_url":"https://api.github.com/users/StephanEwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephanEwen/subscriptions","organizations_url":"https://api.github.com/users/StephanEwen/orgs","repos_url":"https://api.github.com/users/StephanEwen/repos","events_url":"https://api.github.com/users/StephanEwen/events{/privacy}","received_events_url":"https://api.github.com/users/StephanEwen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/StephanEwen/incubator-flink","description":"Mirror of Apache Flink","fork":true,"url":"https://api.github.com/repos/StephanEwen/incubator-flink","forks_url":"https://api.github.com/repos/StephanEwen/incubator-flink/forks","keys_url":"https://api.github.com/repos/StephanEwen/incubator-flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StephanEwen/incubator-flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StephanEwen/incubator-flink/teams","hooks_url":"https://api.github.com/repos/StephanEwen/incubator-flink/hooks","issue_events_url":"https://api.github.com/repos/StephanEwen/incubator-flink/issues/events{/number}","events_url":"https://api.github.com/repos/StephanEwen/incubator-flink/events","assignees_url":"https://api.github.com/repos/StephanEwen/incubator-flink/assignees{/user}","branches_url":"https://api.github.com/repos/StephanEwen/incubator-flink/branches{/branch}","tags_url":"https://api.github.com/repos/StephanEwen/incubator-flink/tags","blobs_url":"https://api.github.com/repos/StephanEwen/incubator-flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StephanEwen/incubator-flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StephanEwen/incubator-flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/StephanEwen/incubator-flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StephanEwen/incubator-flink/statuses/{sha}","languages_url":"https://api.github.com/repos/StephanEwen/incubator-flink/languages","stargazers_url":"https://api.github.com/repos/StephanEwen/incubator-flink/stargazers","contributors_url":"https://api.github.com/repos/StephanEwen/incubator-flink/contributors","subscribers_url":"https://api.github.com/repos/StephanEwen/incubator-flink/subscribers","subscription_url":"https://api.github.com/repos/StephanEwen/incubator-flink/subscription","commits_url":"https://api.github.com/repos/StephanEwen/incubator-flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/StephanEwen/incubator-flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/StephanEwen/incubator-flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/StephanEwen/incubator-flink/issues/comments/{number}","contents_url":"https://api.github.com/repos/StephanEwen/incubator-flink/contents/{+path}","compare_url":"https://api.github.com/repos/StephanEwen/incubator-flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StephanEwen/incubator-flink/merges","archive_url":"https://api.github.com/repos/StephanEwen/incubator-flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StephanEwen/incubator-flink/downloads","issues_url":"https://api.github.com/repos/StephanEwen/incubator-flink/issues{/number}","pulls_url":"https://api.github.com/repos/StephanEwen/incubator-flink/pulls{/number}","milestones_url":"https://api.github.com/repos/StephanEwen/incubator-flink/milestones{/number}","notifications_url":"https://api.github.com/repos/StephanEwen/incubator-flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StephanEwen/incubator-flink/labels{/name}","releases_url":"https://api.github.com/repos/StephanEwen/incubator-flink/releases{/id}","created_at":"2014-06-24T15:57:00Z","updated_at":"2014-06-25T15:03:39Z","pushed_at":"2014-07-31T18:52:57Z","git_url":"git://github.com/StephanEwen/incubator-flink.git","ssh_url":"git@github.com:StephanEwen/incubator-flink.git","clone_url":"https://github.com/StephanEwen/incubator-flink.git","svn_url":"https://github.com/StephanEwen/incubator-flink","homepage":null,"size":27111,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"a45c14b6ddc236f0df62aaad37bb31b9ad8f211c","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=1","gravatar_id":"a676c0bf448fcd49f588249ead719b4c","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":20587599,"name":"incubator-flink","full_name":"apache/incubator-flink","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=1","gravatar_id":"a676c0bf448fcd49f588249ead719b4c","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-flink","description":"Mirror of Apache Flink","fork":false,"url":"https://api.github.com/repos/apache/incubator-flink","forks_url":"https://api.github.com/repos/apache/incubator-flink/forks","keys_url":"https://api.github.com/repos/apache/incubator-flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-flink/teams","hooks_url":"https://api.github.com/repos/apache/incubator-flink/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-flink/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-flink/events","assignees_url":"https://api.github.com/repos/apache/incubator-flink/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-flink/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-flink/tags","blobs_url":"https://api.github.com/repos/apache/incubator-flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-flink/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-flink/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-flink/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-flink/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-flink/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-flink/subscription","commits_url":"https://api.github.com/repos/apache/incubator-flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-flink/issues/comments/{number}","contents_url":"https://api.github.com/repos/apache/incubator-flink/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-flink/merges","archive_url":"https://api.github.com/repos/apache/incubator-flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-flink/downloads","issues_url":"https://api.github.com/repos/apache/incubator-flink/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-flink/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-flink/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-flink/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-flink/releases{/id}","created_at":"2014-06-07T07:00:10Z","updated_at":"2014-07-25T12:43:24Z","pushed_at":"2014-08-01T01:23:50Z","git_url":"git://github.com/apache/incubator-flink.git","ssh_url":"git@github.com:apache/incubator-flink.git","clone_url":"https://github.com/apache/incubator-flink.git","svn_url":"https://github.com/apache/incubator-flink","homepage":null,"size":4743430,"stargazers_count":28,"watchers_count":28,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":40,"mirror_url":"git://git.apache.org/incubator-flink.git","open_issues_count":29,"forks":40,"open_issues":29,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-flink/pulls/84"},"html":{"href":"https://github.com/apache/incubator-flink/pull/84"},"issue":{"href":"https://api.github.com/repos/apache/incubator-flink/issues/84"},"comments":{"href":"https://api.github.com/repos/apache/incubator-flink/issues/84/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-flink/pulls/84/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-flink/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-flink/pulls/84/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-flink/statuses/9ccf913fbe89d1b3fad0f8cf1bf6eaa1f2284125"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":8,"review_comments":0,"commits":3,"additions":1290,"deletions":761,"changed_files":95}}