{"action":"created","comment":{"url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/comments/64599123","id":64599123,"diff_hunk":"@@ -160,14 +192,63 @@ public void update(CRUDOperationContext ctx,\n                 }\n                 docIndex++;\n             }\n+            // if we have any remaining items to update\n+            if (numUpdating > 0) {\n+                try {\n+                    BulkWriteResult result = executeAndLogBulkErrors(bwo);\n+                    numUpdated += result.getModifiedCount();\n+                    numMatched += result.getMatchedCount();\n+                } catch (Exception e) {\n+                    LOGGER.warn(\"Update exception for documents for query: {}\", query.toString());\n+                }\n+            }\n         } finally {\n             if (cursor != null) {\n                 cursor.close();\n             }\n         }\n+        handleBulkWriteError(docUpdateErrors, docUpdateAttempts);\n+\n+        docUpdateActual.stream().filter(doc -> doc != null).forEach(doc -> {\n+            ctx.getFactory().getInterceptors().callInterceptors(InterceptPoint.POST_CRUD_UPDATE_DOC, ctx, doc);\n+        });\n+\n         response.setNumUpdated(numUpdated);\n         response.setNumFailed(numFailed);\n-        response.setNumMatched(docIndex);\n+        response.setNumMatched(numMatched);\n+    }\n+\n+    private void handleBulkWriteError(List<BulkWriteError> errors, List<DocCtx> docs) {\n+        docUpdateActual.addAll(docs);\n+        for (BulkWriteError e : errors) {\n+            DocCtx doc = docs.get(e.getIndex());\n+            // remove any docs from the updated list if they had an error\n+            docUpdateActual.set(e.getIndex(), null);","path":"mongo/src/main/java/com/redhat/lightblue/mongo/crud/IterateAndUpdate.java","position":156,"original_position":156,"commit_id":"29101524440699ee634de5301bf3907ffd20d2e7","original_commit_id":"29101524440699ee634de5301bf3907ffd20d2e7","user":{"login":"BVulaj","id":854769,"avatar_url":"https://avatars.githubusercontent.com/u/854769?v=3","gravatar_id":"","url":"https://api.github.com/users/BVulaj","html_url":"https://github.com/BVulaj","followers_url":"https://api.github.com/users/BVulaj/followers","following_url":"https://api.github.com/users/BVulaj/following{/other_user}","gists_url":"https://api.github.com/users/BVulaj/gists{/gist_id}","starred_url":"https://api.github.com/users/BVulaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BVulaj/subscriptions","organizations_url":"https://api.github.com/users/BVulaj/orgs","repos_url":"https://api.github.com/users/BVulaj/repos","events_url":"https://api.github.com/users/BVulaj/events{/privacy}","received_events_url":"https://api.github.com/users/BVulaj/received_events","type":"User","site_admin":false},"body":"Had initially needed to remove items from the list without affecting indexes, but removed that code before committing.  Will just remove this.","created_at":"2016-05-25T15:52:33Z","updated_at":"2016-05-25T15:52:33Z","html_url":"https://github.com/lightblue-platform/lightblue-mongo/pull/275#discussion_r64599123","pull_request_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/275","_links":{"self":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/comments/64599123"},"html":{"href":"https://github.com/lightblue-platform/lightblue-mongo/pull/275#discussion_r64599123"},"pull_request":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/275"}}},"pull_request":{"url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/275","id":70579980,"html_url":"https://github.com/lightblue-platform/lightblue-mongo/pull/275","diff_url":"https://github.com/lightblue-platform/lightblue-mongo/pull/275.diff","patch_url":"https://github.com/lightblue-platform/lightblue-mongo/pull/275.patch","issue_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/275","number":275,"state":"open","locked":false,"title":"Use mongo bulk updates for update requests","user":{"login":"BVulaj","id":854769,"avatar_url":"https://avatars.githubusercontent.com/u/854769?v=3","gravatar_id":"","url":"https://api.github.com/users/BVulaj","html_url":"https://github.com/BVulaj","followers_url":"https://api.github.com/users/BVulaj/followers","following_url":"https://api.github.com/users/BVulaj/following{/other_user}","gists_url":"https://api.github.com/users/BVulaj/gists{/gist_id}","starred_url":"https://api.github.com/users/BVulaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BVulaj/subscriptions","organizations_url":"https://api.github.com/users/BVulaj/orgs","repos_url":"https://api.github.com/users/BVulaj/repos","events_url":"https://api.github.com/users/BVulaj/events{/privacy}","received_events_url":"https://api.github.com/users/BVulaj/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-18T18:51:35Z","updated_at":"2016-05-25T15:52:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1eecb080c59a76af0d6ca5ecdb333ee2c016aa56","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/275/commits","review_comments_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/275/comments","review_comment_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/275/comments","statuses_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/statuses/29101524440699ee634de5301bf3907ffd20d2e7","head":{"label":"BVulaj:update-bulk","ref":"update-bulk","sha":"29101524440699ee634de5301bf3907ffd20d2e7","user":{"login":"BVulaj","id":854769,"avatar_url":"https://avatars.githubusercontent.com/u/854769?v=3","gravatar_id":"","url":"https://api.github.com/users/BVulaj","html_url":"https://github.com/BVulaj","followers_url":"https://api.github.com/users/BVulaj/followers","following_url":"https://api.github.com/users/BVulaj/following{/other_user}","gists_url":"https://api.github.com/users/BVulaj/gists{/gist_id}","starred_url":"https://api.github.com/users/BVulaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BVulaj/subscriptions","organizations_url":"https://api.github.com/users/BVulaj/orgs","repos_url":"https://api.github.com/users/BVulaj/repos","events_url":"https://api.github.com/users/BVulaj/events{/privacy}","received_events_url":"https://api.github.com/users/BVulaj/received_events","type":"User","site_admin":false},"repo":{"id":42329100,"name":"lightblue-mongo","full_name":"BVulaj/lightblue-mongo","owner":{"login":"BVulaj","id":854769,"avatar_url":"https://avatars.githubusercontent.com/u/854769?v=3","gravatar_id":"","url":"https://api.github.com/users/BVulaj","html_url":"https://github.com/BVulaj","followers_url":"https://api.github.com/users/BVulaj/followers","following_url":"https://api.github.com/users/BVulaj/following{/other_user}","gists_url":"https://api.github.com/users/BVulaj/gists{/gist_id}","starred_url":"https://api.github.com/users/BVulaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BVulaj/subscriptions","organizations_url":"https://api.github.com/users/BVulaj/orgs","repos_url":"https://api.github.com/users/BVulaj/repos","events_url":"https://api.github.com/users/BVulaj/events{/privacy}","received_events_url":"https://api.github.com/users/BVulaj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BVulaj/lightblue-mongo","description":"","fork":true,"url":"https://api.github.com/repos/BVulaj/lightblue-mongo","forks_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/forks","keys_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/teams","hooks_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/hooks","issue_events_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/issues/events{/number}","events_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/events","assignees_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/assignees{/user}","branches_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/branches{/branch}","tags_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/tags","blobs_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/git/refs{/sha}","trees_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/statuses/{sha}","languages_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/languages","stargazers_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/stargazers","contributors_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/contributors","subscribers_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/subscribers","subscription_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/subscription","commits_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/commits{/sha}","git_commits_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/git/commits{/sha}","comments_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/comments{/number}","issue_comment_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/issues/comments{/number}","contents_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/contents/{+path}","compare_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/merges","archive_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/downloads","issues_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/issues{/number}","pulls_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/pulls{/number}","milestones_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/milestones{/number}","notifications_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/labels{/name}","releases_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/releases{/id}","deployments_url":"https://api.github.com/repos/BVulaj/lightblue-mongo/deployments","created_at":"2015-09-11T19:51:46Z","updated_at":"2015-09-11T19:51:47Z","pushed_at":"2016-05-25T14:22:54Z","git_url":"git://github.com/BVulaj/lightblue-mongo.git","ssh_url":"git@github.com:BVulaj/lightblue-mongo.git","clone_url":"https://github.com/BVulaj/lightblue-mongo.git","svn_url":"https://github.com/BVulaj/lightblue-mongo","homepage":null,"size":1622,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"lightblue-platform:master","ref":"master","sha":"787aa4323799a41d575850788dce8b64086dfd72","user":{"login":"lightblue-platform","id":7061725,"avatar_url":"https://avatars.githubusercontent.com/u/7061725?v=3","gravatar_id":"","url":"https://api.github.com/users/lightblue-platform","html_url":"https://github.com/lightblue-platform","followers_url":"https://api.github.com/users/lightblue-platform/followers","following_url":"https://api.github.com/users/lightblue-platform/following{/other_user}","gists_url":"https://api.github.com/users/lightblue-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/lightblue-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightblue-platform/subscriptions","organizations_url":"https://api.github.com/users/lightblue-platform/orgs","repos_url":"https://api.github.com/users/lightblue-platform/repos","events_url":"https://api.github.com/users/lightblue-platform/events{/privacy}","received_events_url":"https://api.github.com/users/lightblue-platform/received_events","type":"Organization","site_admin":false},"repo":{"id":23001350,"name":"lightblue-mongo","full_name":"lightblue-platform/lightblue-mongo","owner":{"login":"lightblue-platform","id":7061725,"avatar_url":"https://avatars.githubusercontent.com/u/7061725?v=3","gravatar_id":"","url":"https://api.github.com/users/lightblue-platform","html_url":"https://github.com/lightblue-platform","followers_url":"https://api.github.com/users/lightblue-platform/followers","following_url":"https://api.github.com/users/lightblue-platform/following{/other_user}","gists_url":"https://api.github.com/users/lightblue-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/lightblue-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightblue-platform/subscriptions","organizations_url":"https://api.github.com/users/lightblue-platform/orgs","repos_url":"https://api.github.com/users/lightblue-platform/repos","events_url":"https://api.github.com/users/lightblue-platform/events{/privacy}","received_events_url":"https://api.github.com/users/lightblue-platform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lightblue-platform/lightblue-mongo","description":"","fork":false,"url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo","forks_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/forks","keys_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/teams","hooks_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/hooks","issue_events_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/events{/number}","events_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/events","assignees_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/assignees{/user}","branches_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/branches{/branch}","tags_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/tags","blobs_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/git/refs{/sha}","trees_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/statuses/{sha}","languages_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/languages","stargazers_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/stargazers","contributors_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/contributors","subscribers_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/subscribers","subscription_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/subscription","commits_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/commits{/sha}","git_commits_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/git/commits{/sha}","comments_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/comments{/number}","issue_comment_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/comments{/number}","contents_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/contents/{+path}","compare_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/merges","archive_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/downloads","issues_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues{/number}","pulls_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls{/number}","milestones_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/milestones{/number}","notifications_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/labels{/name}","releases_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/releases{/id}","deployments_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/deployments","created_at":"2014-08-15T19:57:37Z","updated_at":"2016-01-14T04:22:48Z","pushed_at":"2016-05-25T14:22:54Z","git_url":"git://github.com/lightblue-platform/lightblue-mongo.git","ssh_url":"git@github.com:lightblue-platform/lightblue-mongo.git","clone_url":"https://github.com/lightblue-platform/lightblue-mongo.git","svn_url":"https://github.com/lightblue-platform/lightblue-mongo","homepage":null,"size":1617,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":24,"forks":9,"open_issues":24,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/275"},"html":{"href":"https://github.com/lightblue-platform/lightblue-mongo/pull/275"},"issue":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/275"},"comments":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/275/comments"},"review_comments":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/275/comments"},"review_comment":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/pulls/275/commits"},"statuses":{"href":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/statuses/29101524440699ee634de5301bf3907ffd20d2e7"}}}}
{"actor":{"display_login":"BVulaj"}}