{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/89709726","pull_request_review_id":10247451,"id":89709726,"diff_hunk":"@@ -1424,29 +1431,38 @@ accum.value();\n // returns 10\n {% endhighlight %}\n \n-Programmers can also create their own types by subclassing\n-[AccumulatorParam](api/java/index.html?org/apache/spark/AccumulatorParam.html).\n-The AccumulatorParam interface has two methods: `zero` for providing a \"zero value\" for your data\n-type, and `addInPlace` for adding two values together. For example, supposing we had a `Vector` class\n-representing mathematical vectors, we could write:\n+While this code used the built-in support for accumulators of type Long, programmers can also\n+create their own types by subclassing [AccumulatorV2](api/scala/index.html#org.apache.spark.util.AccumulatorV2).\n+The AccumulatorV2 abstract class has several methods which one has to override:\n+`reset` for resetting the accumulator to zero, `add` for adding another value into the accumulator,\n+and `merge` for merging another same-type accumulator into this one. Other methods that must be overridden\n+are contained in the [API documentation](api/scala/index.html#org.apache.spark.util.AccumulatorV2).\n+For example, supposing we had a `MathVector` class representing mathematical vectors, we could write:\n \n {% highlight java %}\n-class VectorAccumulatorParam implements AccumulatorParam<Vector> {\n-  public Vector zero(Vector initialValue) {\n-    return Vector.zeros(initialValue.size());\n+class MathVectorAccumulatorV2 implements AccumulatorV2<MathVector, MathVector> {\n+\n+  private MathVector mathVector = MathVector.newZeroVector();\n+\n+  public void reset() {\n+    mathVector.reset();\n   }\n-  public Vector addInPlace(Vector v1, Vector v2) {\n-    v1.addInPlace(v2); return v1;\n+\n+  public void add(MathVector v) {\n+    mathVector.add(v);\n   }\n+\n+  ...\n }\n \n-// Then, create an Accumulator of this type:\n-Accumulator<Vector> vecAccum = sc.accumulator(new Vector(...), new VectorAccumulatorParam());\n+// Create an instance\n+MathVectorAccumulatorV2 mathVectorAcc = new MathVectorAccumulatorV2();\n+// Register it\n+jsc.sc().register(mathVectorAcc, \"MathVectorAcc1\");\n {% endhighlight %}\n \n-In Java, Spark also supports the more general [Accumulable](api/java/index.html?org/apache/spark/Accumulable.html)\n-interface to accumulate data where the resulting type is not the same as the elements added (e.g. build\n-a list by collecting together elements).\n+Note that, when programmers define their own type of AccumulatorV2,the resulting type can be different","path":"docs/programming-guide.md","position":100,"original_position":100,"commit_id":"f4388a84181e7c40003db0b1574602350160721a","original_commit_id":"f4388a84181e7c40003db0b1574602350160721a","user":{"login":"HyukjinKwon","id":6477701,"avatar_url":"https://avatars.githubusercontent.com/u/6477701?v=3","gravatar_id":"","url":"https://api.github.com/users/HyukjinKwon","html_url":"https://github.com/HyukjinKwon","followers_url":"https://api.github.com/users/HyukjinKwon/followers","following_url":"https://api.github.com/users/HyukjinKwon/following{/other_user}","gists_url":"https://api.github.com/users/HyukjinKwon/gists{/gist_id}","starred_url":"https://api.github.com/users/HyukjinKwon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HyukjinKwon/subscriptions","organizations_url":"https://api.github.com/users/HyukjinKwon/orgs","repos_url":"https://api.github.com/users/HyukjinKwon/repos","events_url":"https://api.github.com/users/HyukjinKwon/events{/privacy}","received_events_url":"https://api.github.com/users/HyukjinKwon/received_events","type":"User","site_admin":false},"body":"I was reading this for my fun but I just found a possible super minor `AccumulatorV2,the` to `AccumulatorV2, the`","created_at":"2016-11-28T02:28:17Z","updated_at":"2016-11-28T02:28:17Z","html_url":"https://github.com/apache/spark/pull/16024#discussion_r89709726","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/16024","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/89709726"},"html":{"href":"https://github.com/apache/spark/pull/16024#discussion_r89709726"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/16024"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/16024","id":95418434,"html_url":"https://github.com/apache/spark/pull/16024","diff_url":"https://github.com/apache/spark/pull/16024.diff","patch_url":"https://github.com/apache/spark/pull/16024.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/16024","number":16024,"state":"open","locked":false,"title":"[MINOR][DOCS] Updates to the Accumulator example in the programming guide. Fixed typos, AccumulatorV2 in Java","user":{"login":"aokolnychyi","id":6235869,"avatar_url":"https://avatars.githubusercontent.com/u/6235869?v=3","gravatar_id":"","url":"https://api.github.com/users/aokolnychyi","html_url":"https://github.com/aokolnychyi","followers_url":"https://api.github.com/users/aokolnychyi/followers","following_url":"https://api.github.com/users/aokolnychyi/following{/other_user}","gists_url":"https://api.github.com/users/aokolnychyi/gists{/gist_id}","starred_url":"https://api.github.com/users/aokolnychyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aokolnychyi/subscriptions","organizations_url":"https://api.github.com/users/aokolnychyi/orgs","repos_url":"https://api.github.com/users/aokolnychyi/repos","events_url":"https://api.github.com/users/aokolnychyi/events{/privacy}","received_events_url":"https://api.github.com/users/aokolnychyi/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nThis pull request contains updates to Scala and Java Accumulator code snippets in the programming guide. \r\n\r\n- For Scala, the pull request fixes the signature of the 'add()' method in the custom Accumulator, which contained two params (as the old AccumulatorParam) instead of one (as in AccumulatorV2). \r\n\r\n- The Java example was updated to use the AccumulatorV2 class since AccumulatorParam is marked as deprecated.  \r\n\r\n- Scala and Java examples are more consistent now.\r\n\r\n## How was this patch tested?\r\n\r\nThis patch was tested manually by building the docs locally.\r\n\r\n![image](https://cloud.githubusercontent.com/assets/6235869/20652099/77d98d18-b4f3-11e6-8565-a995fe8cf8e5.png)\r\n\r\n","created_at":"2016-11-27T22:00:17Z","updated_at":"2016-11-28T02:28:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06f604042adc5bce4e048957880355aa58f1fadc","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/16024/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/16024/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/16024/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/f4388a84181e7c40003db0b1574602350160721a","head":{"label":"aokolnychyi:fixed_accumulator_example","ref":"fixed_accumulator_example","sha":"f4388a84181e7c40003db0b1574602350160721a","user":{"login":"aokolnychyi","id":6235869,"avatar_url":"https://avatars.githubusercontent.com/u/6235869?v=3","gravatar_id":"","url":"https://api.github.com/users/aokolnychyi","html_url":"https://github.com/aokolnychyi","followers_url":"https://api.github.com/users/aokolnychyi/followers","following_url":"https://api.github.com/users/aokolnychyi/following{/other_user}","gists_url":"https://api.github.com/users/aokolnychyi/gists{/gist_id}","starred_url":"https://api.github.com/users/aokolnychyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aokolnychyi/subscriptions","organizations_url":"https://api.github.com/users/aokolnychyi/orgs","repos_url":"https://api.github.com/users/aokolnychyi/repos","events_url":"https://api.github.com/users/aokolnychyi/events{/privacy}","received_events_url":"https://api.github.com/users/aokolnychyi/received_events","type":"User","site_admin":false},"repo":{"id":61945043,"name":"spark","full_name":"aokolnychyi/spark","owner":{"login":"aokolnychyi","id":6235869,"avatar_url":"https://avatars.githubusercontent.com/u/6235869?v=3","gravatar_id":"","url":"https://api.github.com/users/aokolnychyi","html_url":"https://github.com/aokolnychyi","followers_url":"https://api.github.com/users/aokolnychyi/followers","following_url":"https://api.github.com/users/aokolnychyi/following{/other_user}","gists_url":"https://api.github.com/users/aokolnychyi/gists{/gist_id}","starred_url":"https://api.github.com/users/aokolnychyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aokolnychyi/subscriptions","organizations_url":"https://api.github.com/users/aokolnychyi/orgs","repos_url":"https://api.github.com/users/aokolnychyi/repos","events_url":"https://api.github.com/users/aokolnychyi/events{/privacy}","received_events_url":"https://api.github.com/users/aokolnychyi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aokolnychyi/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/aokolnychyi/spark","forks_url":"https://api.github.com/repos/aokolnychyi/spark/forks","keys_url":"https://api.github.com/repos/aokolnychyi/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aokolnychyi/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aokolnychyi/spark/teams","hooks_url":"https://api.github.com/repos/aokolnychyi/spark/hooks","issue_events_url":"https://api.github.com/repos/aokolnychyi/spark/issues/events{/number}","events_url":"https://api.github.com/repos/aokolnychyi/spark/events","assignees_url":"https://api.github.com/repos/aokolnychyi/spark/assignees{/user}","branches_url":"https://api.github.com/repos/aokolnychyi/spark/branches{/branch}","tags_url":"https://api.github.com/repos/aokolnychyi/spark/tags","blobs_url":"https://api.github.com/repos/aokolnychyi/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aokolnychyi/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aokolnychyi/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/aokolnychyi/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aokolnychyi/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/aokolnychyi/spark/languages","stargazers_url":"https://api.github.com/repos/aokolnychyi/spark/stargazers","contributors_url":"https://api.github.com/repos/aokolnychyi/spark/contributors","subscribers_url":"https://api.github.com/repos/aokolnychyi/spark/subscribers","subscription_url":"https://api.github.com/repos/aokolnychyi/spark/subscription","commits_url":"https://api.github.com/repos/aokolnychyi/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/aokolnychyi/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/aokolnychyi/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/aokolnychyi/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/aokolnychyi/spark/contents/{+path}","compare_url":"https://api.github.com/repos/aokolnychyi/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aokolnychyi/spark/merges","archive_url":"https://api.github.com/repos/aokolnychyi/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aokolnychyi/spark/downloads","issues_url":"https://api.github.com/repos/aokolnychyi/spark/issues{/number}","pulls_url":"https://api.github.com/repos/aokolnychyi/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/aokolnychyi/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/aokolnychyi/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aokolnychyi/spark/labels{/name}","releases_url":"https://api.github.com/repos/aokolnychyi/spark/releases{/id}","deployments_url":"https://api.github.com/repos/aokolnychyi/spark/deployments","created_at":"2016-06-25T13:46:06Z","updated_at":"2016-06-25T13:46:28Z","pushed_at":"2016-11-27T21:31:49Z","git_url":"git://github.com/aokolnychyi/spark.git","ssh_url":"git@github.com:aokolnychyi/spark.git","clone_url":"https://github.com/aokolnychyi/spark.git","svn_url":"https://github.com/aokolnychyi/spark","homepage":null,"size":247618,"stargazers_count":0,"watchers_count":0,"language":"Scala","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:master","ref":"master","sha":"9c03c564605783d8e94f6795432bb59c33933e52","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":17165658,"name":"spark","full_name":"apache/spark","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/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2016-11-28T02:02:32Z","pushed_at":"2016-11-28T02:08:52Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":615247,"stargazers_count":10870,"watchers_count":10870,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10139,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":456,"forks":10139,"open_issues":456,"watchers":10870,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/16024"},"html":{"href":"https://github.com/apache/spark/pull/16024"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/16024"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/16024/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/16024/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/16024/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/f4388a84181e7c40003db0b1574602350160721a"}}}}
{"actor":{"display_login":"HyukjinKwon"}}