{"action":"created","comment":{"url":"https://api.github.com/repos/stephenh/joist/pulls/comments/50578496","id":50578496,"diff_hunk":"@@ -152,6 +149,37 @@ void setUpdater(Updater updater) {\n     }\n   }\n \n+  <T extends DomainObject> Iterator<List<T>> batches(Class<T> type, Integer batchSize) {\n+    if (batchSize > this.identityMap.getCurrentSizeLimit()) {\n+      throw new IllegalArgumentException(\n+        \"Batch size: \" + batchSize + \" cannot be larger than current size limit: \" + this.identityMap.getCurrentSizeLimit());\n+    }\n+    Alias<T> a = AliasRegistry.get(type);\n+    UnitOfWork uow = this;\n+    Iterator<List<T>> it = new Iterator<List<T>>() {\n+\n+      private Integer offset = 0;\n+      private int total = (int) Select.from(a).count();\n+\n+      @Override\n+      public boolean hasNext() {\n+        return this.offset < this.total;\n+      }\n+\n+      @Override\n+      public List<T> next() {\n+        uow.flush();\n+        uow.identityMap.enableBatchMode();\n+        List<Long> ids = Select.from(a).limit(batchSize).offset(this.offset).listIds();\n+        this.offset += batchSize;","path":"domain/src/main/java/joist/domain/uow/UnitOfWork.java","position":39,"original_position":39,"commit_id":"2e15bef1df40d18613fb72a749aa27dcc581e29d","original_commit_id":"2e15bef1df40d18613fb72a749aa27dcc581e29d","user":{"login":"cbrentharris","id":5912495,"avatar_url":"https://avatars.githubusercontent.com/u/5912495?v=3","gravatar_id":"","url":"https://api.github.com/users/cbrentharris","html_url":"https://github.com/cbrentharris","followers_url":"https://api.github.com/users/cbrentharris/followers","following_url":"https://api.github.com/users/cbrentharris/following{/other_user}","gists_url":"https://api.github.com/users/cbrentharris/gists{/gist_id}","starred_url":"https://api.github.com/users/cbrentharris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbrentharris/subscriptions","organizations_url":"https://api.github.com/users/cbrentharris/orgs","repos_url":"https://api.github.com/users/cbrentharris/repos","events_url":"https://api.github.com/users/cbrentharris/events{/privacy}","received_events_url":"https://api.github.com/users/cbrentharris/received_events","type":"User","site_admin":false},"body":"Need to add the edge case where total - offset < batchSize","created_at":"2016-01-22T19:21:06Z","updated_at":"2016-01-22T19:21:06Z","html_url":"https://github.com/stephenh/joist/pull/15#discussion_r50578496","pull_request_url":"https://api.github.com/repos/stephenh/joist/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/stephenh/joist/pulls/comments/50578496"},"html":{"href":"https://github.com/stephenh/joist/pull/15#discussion_r50578496"},"pull_request":{"href":"https://api.github.com/repos/stephenh/joist/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/stephenh/joist/pulls/15","id":56928025,"html_url":"https://github.com/stephenh/joist/pull/15","diff_url":"https://github.com/stephenh/joist/pull/15.diff","patch_url":"https://github.com/stephenh/joist/pull/15.patch","issue_url":"https://api.github.com/repos/stephenh/joist/issues/15","number":15,"state":"open","locked":false,"title":"Feature : Find in batches","user":{"login":"cbrentharris","id":5912495,"avatar_url":"https://avatars.githubusercontent.com/u/5912495?v=3","gravatar_id":"","url":"https://api.github.com/users/cbrentharris","html_url":"https://github.com/cbrentharris","followers_url":"https://api.github.com/users/cbrentharris/followers","following_url":"https://api.github.com/users/cbrentharris/following{/other_user}","gists_url":"https://api.github.com/users/cbrentharris/gists{/gist_id}","starred_url":"https://api.github.com/users/cbrentharris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbrentharris/subscriptions","organizations_url":"https://api.github.com/users/cbrentharris/orgs","repos_url":"https://api.github.com/users/cbrentharris/repos","events_url":"https://api.github.com/users/cbrentharris/events{/privacy}","received_events_url":"https://api.github.com/users/cbrentharris/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-22T19:07:23Z","updated_at":"2016-01-22T19:21:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6acc69b5b2a6f25238b4bfc8704f5b2c63d0fefc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/stephenh/joist/pulls/15/commits","review_comments_url":"https://api.github.com/repos/stephenh/joist/pulls/15/comments","review_comment_url":"https://api.github.com/repos/stephenh/joist/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stephenh/joist/issues/15/comments","statuses_url":"https://api.github.com/repos/stephenh/joist/statuses/2e15bef1df40d18613fb72a749aa27dcc581e29d","head":{"label":"cbrentharris:find_in_batches","ref":"find_in_batches","sha":"2e15bef1df40d18613fb72a749aa27dcc581e29d","user":{"login":"cbrentharris","id":5912495,"avatar_url":"https://avatars.githubusercontent.com/u/5912495?v=3","gravatar_id":"","url":"https://api.github.com/users/cbrentharris","html_url":"https://github.com/cbrentharris","followers_url":"https://api.github.com/users/cbrentharris/followers","following_url":"https://api.github.com/users/cbrentharris/following{/other_user}","gists_url":"https://api.github.com/users/cbrentharris/gists{/gist_id}","starred_url":"https://api.github.com/users/cbrentharris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbrentharris/subscriptions","organizations_url":"https://api.github.com/users/cbrentharris/orgs","repos_url":"https://api.github.com/users/cbrentharris/repos","events_url":"https://api.github.com/users/cbrentharris/events{/privacy}","received_events_url":"https://api.github.com/users/cbrentharris/received_events","type":"User","site_admin":false},"repo":{"id":45626061,"name":"joist","full_name":"cbrentharris/joist","owner":{"login":"cbrentharris","id":5912495,"avatar_url":"https://avatars.githubusercontent.com/u/5912495?v=3","gravatar_id":"","url":"https://api.github.com/users/cbrentharris","html_url":"https://github.com/cbrentharris","followers_url":"https://api.github.com/users/cbrentharris/followers","following_url":"https://api.github.com/users/cbrentharris/following{/other_user}","gists_url":"https://api.github.com/users/cbrentharris/gists{/gist_id}","starred_url":"https://api.github.com/users/cbrentharris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbrentharris/subscriptions","organizations_url":"https://api.github.com/users/cbrentharris/orgs","repos_url":"https://api.github.com/users/cbrentharris/repos","events_url":"https://api.github.com/users/cbrentharris/events{/privacy}","received_events_url":"https://api.github.com/users/cbrentharris/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cbrentharris/joist","description":"a orm based on code generation","fork":true,"url":"https://api.github.com/repos/cbrentharris/joist","forks_url":"https://api.github.com/repos/cbrentharris/joist/forks","keys_url":"https://api.github.com/repos/cbrentharris/joist/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cbrentharris/joist/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cbrentharris/joist/teams","hooks_url":"https://api.github.com/repos/cbrentharris/joist/hooks","issue_events_url":"https://api.github.com/repos/cbrentharris/joist/issues/events{/number}","events_url":"https://api.github.com/repos/cbrentharris/joist/events","assignees_url":"https://api.github.com/repos/cbrentharris/joist/assignees{/user}","branches_url":"https://api.github.com/repos/cbrentharris/joist/branches{/branch}","tags_url":"https://api.github.com/repos/cbrentharris/joist/tags","blobs_url":"https://api.github.com/repos/cbrentharris/joist/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cbrentharris/joist/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cbrentharris/joist/git/refs{/sha}","trees_url":"https://api.github.com/repos/cbrentharris/joist/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cbrentharris/joist/statuses/{sha}","languages_url":"https://api.github.com/repos/cbrentharris/joist/languages","stargazers_url":"https://api.github.com/repos/cbrentharris/joist/stargazers","contributors_url":"https://api.github.com/repos/cbrentharris/joist/contributors","subscribers_url":"https://api.github.com/repos/cbrentharris/joist/subscribers","subscription_url":"https://api.github.com/repos/cbrentharris/joist/subscription","commits_url":"https://api.github.com/repos/cbrentharris/joist/commits{/sha}","git_commits_url":"https://api.github.com/repos/cbrentharris/joist/git/commits{/sha}","comments_url":"https://api.github.com/repos/cbrentharris/joist/comments{/number}","issue_comment_url":"https://api.github.com/repos/cbrentharris/joist/issues/comments{/number}","contents_url":"https://api.github.com/repos/cbrentharris/joist/contents/{+path}","compare_url":"https://api.github.com/repos/cbrentharris/joist/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cbrentharris/joist/merges","archive_url":"https://api.github.com/repos/cbrentharris/joist/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cbrentharris/joist/downloads","issues_url":"https://api.github.com/repos/cbrentharris/joist/issues{/number}","pulls_url":"https://api.github.com/repos/cbrentharris/joist/pulls{/number}","milestones_url":"https://api.github.com/repos/cbrentharris/joist/milestones{/number}","notifications_url":"https://api.github.com/repos/cbrentharris/joist/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cbrentharris/joist/labels{/name}","releases_url":"https://api.github.com/repos/cbrentharris/joist/releases{/id}","deployments_url":"https://api.github.com/repos/cbrentharris/joist/deployments","created_at":"2015-11-05T17:02:25Z","updated_at":"2016-01-21T23:09:50Z","pushed_at":"2016-01-22T19:06:41Z","git_url":"git://github.com/cbrentharris/joist.git","ssh_url":"git@github.com:cbrentharris/joist.git","clone_url":"https://github.com/cbrentharris/joist.git","svn_url":"https://github.com/cbrentharris/joist","homepage":"http://joist.ws","size":58099,"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":"stephenh:master","ref":"master","sha":"b5338028ca0c963c4ad3650255e4b69e7c838e94","user":{"login":"stephenh","id":6401,"avatar_url":"https://avatars.githubusercontent.com/u/6401?v=3","gravatar_id":"","url":"https://api.github.com/users/stephenh","html_url":"https://github.com/stephenh","followers_url":"https://api.github.com/users/stephenh/followers","following_url":"https://api.github.com/users/stephenh/following{/other_user}","gists_url":"https://api.github.com/users/stephenh/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenh/subscriptions","organizations_url":"https://api.github.com/users/stephenh/orgs","repos_url":"https://api.github.com/users/stephenh/repos","events_url":"https://api.github.com/users/stephenh/events{/privacy}","received_events_url":"https://api.github.com/users/stephenh/received_events","type":"User","site_admin":false},"repo":{"id":56904,"name":"joist","full_name":"stephenh/joist","owner":{"login":"stephenh","id":6401,"avatar_url":"https://avatars.githubusercontent.com/u/6401?v=3","gravatar_id":"","url":"https://api.github.com/users/stephenh","html_url":"https://github.com/stephenh","followers_url":"https://api.github.com/users/stephenh/followers","following_url":"https://api.github.com/users/stephenh/following{/other_user}","gists_url":"https://api.github.com/users/stephenh/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenh/subscriptions","organizations_url":"https://api.github.com/users/stephenh/orgs","repos_url":"https://api.github.com/users/stephenh/repos","events_url":"https://api.github.com/users/stephenh/events{/privacy}","received_events_url":"https://api.github.com/users/stephenh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stephenh/joist","description":"a orm based on code generation","fork":false,"url":"https://api.github.com/repos/stephenh/joist","forks_url":"https://api.github.com/repos/stephenh/joist/forks","keys_url":"https://api.github.com/repos/stephenh/joist/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stephenh/joist/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stephenh/joist/teams","hooks_url":"https://api.github.com/repos/stephenh/joist/hooks","issue_events_url":"https://api.github.com/repos/stephenh/joist/issues/events{/number}","events_url":"https://api.github.com/repos/stephenh/joist/events","assignees_url":"https://api.github.com/repos/stephenh/joist/assignees{/user}","branches_url":"https://api.github.com/repos/stephenh/joist/branches{/branch}","tags_url":"https://api.github.com/repos/stephenh/joist/tags","blobs_url":"https://api.github.com/repos/stephenh/joist/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stephenh/joist/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stephenh/joist/git/refs{/sha}","trees_url":"https://api.github.com/repos/stephenh/joist/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stephenh/joist/statuses/{sha}","languages_url":"https://api.github.com/repos/stephenh/joist/languages","stargazers_url":"https://api.github.com/repos/stephenh/joist/stargazers","contributors_url":"https://api.github.com/repos/stephenh/joist/contributors","subscribers_url":"https://api.github.com/repos/stephenh/joist/subscribers","subscription_url":"https://api.github.com/repos/stephenh/joist/subscription","commits_url":"https://api.github.com/repos/stephenh/joist/commits{/sha}","git_commits_url":"https://api.github.com/repos/stephenh/joist/git/commits{/sha}","comments_url":"https://api.github.com/repos/stephenh/joist/comments{/number}","issue_comment_url":"https://api.github.com/repos/stephenh/joist/issues/comments{/number}","contents_url":"https://api.github.com/repos/stephenh/joist/contents/{+path}","compare_url":"https://api.github.com/repos/stephenh/joist/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stephenh/joist/merges","archive_url":"https://api.github.com/repos/stephenh/joist/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stephenh/joist/downloads","issues_url":"https://api.github.com/repos/stephenh/joist/issues{/number}","pulls_url":"https://api.github.com/repos/stephenh/joist/pulls{/number}","milestones_url":"https://api.github.com/repos/stephenh/joist/milestones{/number}","notifications_url":"https://api.github.com/repos/stephenh/joist/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stephenh/joist/labels{/name}","releases_url":"https://api.github.com/repos/stephenh/joist/releases{/id}","deployments_url":"https://api.github.com/repos/stephenh/joist/deployments","created_at":"2008-09-26T23:39:03Z","updated_at":"2016-01-04T21:16:13Z","pushed_at":"2016-01-22T19:07:23Z","git_url":"git://github.com/stephenh/joist.git","ssh_url":"git@github.com:stephenh/joist.git","clone_url":"https://github.com/stephenh/joist.git","svn_url":"https://github.com/stephenh/joist","homepage":"http://joist.ws","size":58104,"stargazers_count":25,"watchers_count":25,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":3,"forks":9,"open_issues":3,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stephenh/joist/pulls/15"},"html":{"href":"https://github.com/stephenh/joist/pull/15"},"issue":{"href":"https://api.github.com/repos/stephenh/joist/issues/15"},"comments":{"href":"https://api.github.com/repos/stephenh/joist/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/stephenh/joist/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/stephenh/joist/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stephenh/joist/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/stephenh/joist/statuses/2e15bef1df40d18613fb72a749aa27dcc581e29d"}}}}