{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/75566392","id":75566392,"diff_hunk":"@@ -889,21 +892,42 @@ private class PythonAccumulatorParam(@transient private val serverHost: String,\n     socket\n   }\n \n-  override def zero(value: JList[Array[Byte]]): JList[Array[Byte]] = new JArrayList\n+  override def reset(): Unit = {\n+    this._acc = Collections.synchronizedList(new JArrayList[Array[Byte]])\n+  }\n+\n+  override def isZero: Boolean = {\n+    this._acc.isEmpty\n+  }\n+\n+  override def copyAndReset(): PythonAccumulatorV2 = new PythonAccumulatorV2(serverHost, serverPort)\n+\n+  override def copy(): PythonAccumulatorV2 = {\n+    val newAcc = new PythonAccumulatorV2(serverHost, serverPort)\n+    newAcc._acc.addAll(this._acc)\n+    newAcc\n+  }\n+\n+  // This happens on the worker node, where we just want to remember all the updates\n+  override def add(val2: JList[Array[Byte]]): Unit = {\n+    _acc.addAll(val2)\n+  }\n+\n \n-  override def addInPlace(val1: JList[Array[Byte]], val2: JList[Array[Byte]])\n-      : JList[Array[Byte]] = synchronized {\n+  override def merge(other: AccumulatorV2[JList[Array[Byte]], JList[Array[Byte]]]): Unit = {\n+    val otherPythonAccumulator = other.asInstanceOf[PythonAccumulatorV2]\n+    // This conditional isn't strictly speaking needed - merging only currently happens on the\n+    // driver program - but that isn't gauranteed so incase this changes.\n     if (serverHost == null) {\n-      // This happens on the worker node, where we just want to remember all the updates\n-      val1.addAll(val2)\n-      val1\n+      // We are on the worker\n+      add(otherPythonAccumulator._acc)\n     } else {\n       // This happens on the master, where we pass the updates to Python through a socket\n       val socket = openSocket()\n       val in = socket.getInputStream\n       val out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream, bufferSize))\n-      out.writeInt(val2.size)\n-      for (array <- val2.asScala) {\n+      out.writeInt(otherPythonAccumulator._acc.size)","path":"core/src/main/scala/org/apache/spark/api/python/PythonRDD.scala","position":null,"original_position":91,"commit_id":"04a1d3792a0624baf0230673ee101da635d0a8f0","original_commit_id":"cc5f4352950f338afeecf1e4f5eaceae853b1520","user":{"login":"holdenk","id":59893,"avatar_url":"https://avatars.githubusercontent.com/u/59893?v=3","gravatar_id":"","url":"https://api.github.com/users/holdenk","html_url":"https://github.com/holdenk","followers_url":"https://api.github.com/users/holdenk/followers","following_url":"https://api.github.com/users/holdenk/following{/other_user}","gists_url":"https://api.github.com/users/holdenk/gists{/gist_id}","starred_url":"https://api.github.com/users/holdenk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holdenk/subscriptions","organizations_url":"https://api.github.com/users/holdenk/orgs","repos_url":"https://api.github.com/users/holdenk/repos","events_url":"https://api.github.com/users/holdenk/events{/privacy}","received_events_url":"https://api.github.com/users/holdenk/received_events","type":"User","site_admin":false},"body":"I've gone ahead and added the requested synchronization :)","created_at":"2016-08-19T23:51:49Z","updated_at":"2016-08-19T23:51:49Z","html_url":"https://github.com/apache/spark/pull/14467#discussion_r75566392","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/14467","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/75566392"},"html":{"href":"https://github.com/apache/spark/pull/14467#discussion_r75566392"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/14467"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/14467","id":79816363,"html_url":"https://github.com/apache/spark/pull/14467","diff_url":"https://github.com/apache/spark/pull/14467.diff","patch_url":"https://github.com/apache/spark/pull/14467.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/14467","number":14467,"state":"open","locked":false,"title":"[SPARK-16861][PYSPARK][CORE] Refactor PySpark accumulator API on top of Accumulator V2","user":{"login":"holdenk","id":59893,"avatar_url":"https://avatars.githubusercontent.com/u/59893?v=3","gravatar_id":"","url":"https://api.github.com/users/holdenk","html_url":"https://github.com/holdenk","followers_url":"https://api.github.com/users/holdenk/followers","following_url":"https://api.github.com/users/holdenk/following{/other_user}","gists_url":"https://api.github.com/users/holdenk/gists{/gist_id}","starred_url":"https://api.github.com/users/holdenk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holdenk/subscriptions","organizations_url":"https://api.github.com/users/holdenk/orgs","repos_url":"https://api.github.com/users/holdenk/repos","events_url":"https://api.github.com/users/holdenk/events{/privacy}","received_events_url":"https://api.github.com/users/holdenk/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nMove the internals of the PySpark accumulator API from the old deprecated API on top of the new accumulator API.\r\n\r\n## How was this patch tested?\r\n\r\nThe existing PySpark accumulator tests (both unit tests and doc tests at the start of accumulator.py).","created_at":"2016-08-02T21:57:58Z","updated_at":"2016-08-19T23:51:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8fb08d5c121579f93a0e881a0820725ff4023f41","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/14467/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/14467/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/14467/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/04a1d3792a0624baf0230673ee101da635d0a8f0","head":{"label":"holdenk:SPARK-16861-refactor-pyspark-accumulator-api","ref":"SPARK-16861-refactor-pyspark-accumulator-api","sha":"04a1d3792a0624baf0230673ee101da635d0a8f0","user":{"login":"holdenk","id":59893,"avatar_url":"https://avatars.githubusercontent.com/u/59893?v=3","gravatar_id":"","url":"https://api.github.com/users/holdenk","html_url":"https://github.com/holdenk","followers_url":"https://api.github.com/users/holdenk/followers","following_url":"https://api.github.com/users/holdenk/following{/other_user}","gists_url":"https://api.github.com/users/holdenk/gists{/gist_id}","starred_url":"https://api.github.com/users/holdenk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holdenk/subscriptions","organizations_url":"https://api.github.com/users/holdenk/orgs","repos_url":"https://api.github.com/users/holdenk/repos","events_url":"https://api.github.com/users/holdenk/events{/privacy}","received_events_url":"https://api.github.com/users/holdenk/received_events","type":"User","site_admin":false},"repo":{"id":17235154,"name":"spark","full_name":"holdenk/spark","owner":{"login":"holdenk","id":59893,"avatar_url":"https://avatars.githubusercontent.com/u/59893?v=3","gravatar_id":"","url":"https://api.github.com/users/holdenk","html_url":"https://github.com/holdenk","followers_url":"https://api.github.com/users/holdenk/followers","following_url":"https://api.github.com/users/holdenk/following{/other_user}","gists_url":"https://api.github.com/users/holdenk/gists{/gist_id}","starred_url":"https://api.github.com/users/holdenk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holdenk/subscriptions","organizations_url":"https://api.github.com/users/holdenk/orgs","repos_url":"https://api.github.com/users/holdenk/repos","events_url":"https://api.github.com/users/holdenk/events{/privacy}","received_events_url":"https://api.github.com/users/holdenk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/holdenk/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/holdenk/spark","forks_url":"https://api.github.com/repos/holdenk/spark/forks","keys_url":"https://api.github.com/repos/holdenk/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/holdenk/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/holdenk/spark/teams","hooks_url":"https://api.github.com/repos/holdenk/spark/hooks","issue_events_url":"https://api.github.com/repos/holdenk/spark/issues/events{/number}","events_url":"https://api.github.com/repos/holdenk/spark/events","assignees_url":"https://api.github.com/repos/holdenk/spark/assignees{/user}","branches_url":"https://api.github.com/repos/holdenk/spark/branches{/branch}","tags_url":"https://api.github.com/repos/holdenk/spark/tags","blobs_url":"https://api.github.com/repos/holdenk/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/holdenk/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/holdenk/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/holdenk/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/holdenk/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/holdenk/spark/languages","stargazers_url":"https://api.github.com/repos/holdenk/spark/stargazers","contributors_url":"https://api.github.com/repos/holdenk/spark/contributors","subscribers_url":"https://api.github.com/repos/holdenk/spark/subscribers","subscription_url":"https://api.github.com/repos/holdenk/spark/subscription","commits_url":"https://api.github.com/repos/holdenk/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/holdenk/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/holdenk/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/holdenk/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/holdenk/spark/contents/{+path}","compare_url":"https://api.github.com/repos/holdenk/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/holdenk/spark/merges","archive_url":"https://api.github.com/repos/holdenk/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/holdenk/spark/downloads","issues_url":"https://api.github.com/repos/holdenk/spark/issues{/number}","pulls_url":"https://api.github.com/repos/holdenk/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/holdenk/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/holdenk/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/holdenk/spark/labels{/name}","releases_url":"https://api.github.com/repos/holdenk/spark/releases{/id}","deployments_url":"https://api.github.com/repos/holdenk/spark/deployments","created_at":"2014-02-27T03:28:28Z","updated_at":"2015-11-05T04:52:38Z","pushed_at":"2016-08-19T01:17:56Z","git_url":"git://github.com/holdenk/spark.git","ssh_url":"git@github.com:holdenk/spark.git","clone_url":"https://github.com/holdenk/spark.git","svn_url":"https://github.com/holdenk/spark","homepage":null,"size":167831,"stargazers_count":3,"watchers_count":3,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"b72bb62d421840f82d663c6b8e3922bd14383fbb","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-08-19T20:57:14Z","pushed_at":"2016-08-19T23:33:39Z","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":506900,"stargazers_count":9714,"watchers_count":9714,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9041,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":480,"forks":9041,"open_issues":480,"watchers":9714,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/14467"},"html":{"href":"https://github.com/apache/spark/pull/14467"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/14467"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/14467/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/14467/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/14467/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/04a1d3792a0624baf0230673ee101da635d0a8f0"}}}}
{"actor":{"display_login":"holdenk"}}