GitHub PullRequestReviewCommentEvent at 2014-07-09 05:47:24
Repository: spark
Actor: mengxr
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/14694378","id":14694378,"diff_hunk":"@@ -83,6 +83,125 @@ class PairRDDFunctionsSuite extends FunSuite with SharedSparkContext {\n     assert(valuesFor2.toList.sorted === List(1))\n   }\n \n+  test(\"sampleByKey\") {\n+    def stratifier (fractionPositive: Double) = {\n+      (x: Int) => if (x % 10 < (10 * fractionPositive).toInt) \"1\" else \"0\"\n+    }\n+\n+    def checkSize(exact: Boolean,\n+        withReplacement: Boolean,\n+        expected: Long,\n+        actual: Long,\n+        p: Double): Boolean = {\n+      if (exact) {\n+        return expected == actual\n+      }\n+      val stdev = if (withReplacement) math.sqrt(expected) else math.sqrt(expected * p * (1 - p))\n+      // Very forgiving margin since we're dealing with very small sample sizes most of the time\n+      math.abs(actual - expected) <= 6 * stdev\n+    }\n+\n+    // Without replacement validation\n+    def takeSampleAndValidateBernoulli(stratifiedData: RDD[(String, Int)],\n+        exact: Boolean,\n+        samplingRate: Double,\n+        seed: Long,\n+        n: Long) = {\n+      val expectedSampleSize = stratifiedData.countByKey().mapValues(count =>","path":"core/src/test/scala/org/apache/spark/rdd/PairRDDFunctionsSuite.scala","position":28,"original_position":28,"commit_id":"a10e68dd9c23b0fc1f25effd9ccd0ac3e7299206","original_commit_id":"a10e68dd9c23b0fc1f25effd9ccd0ac3e7299206","user":{"login":"mengxr","id":829644,"avatar_url":"https://avatars.githubusercontent.com/u/829644?","gravatar_id":"0e16fce91950d1b5a312649751ff1b14","url":"https://api.github.com/users/mengxr","html_url":"https://github.com/mengxr","followers_url":"https://api.github.com/users/mengxr/followers","following_url":"https://api.github.com/users/mengxr/following{/other_user}","gists_url":"https://api.github.com/users/mengxr/gists{/gist_id}","starred_url":"https://api.github.com/users/mengxr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mengxr/subscriptions","organizations_url":"https://api.github.com/users/mengxr/orgs","repos_url":"https://api.github.com/users/mengxr/repos","events_url":"https://api.github.com/users/mengxr/events{/privacy}","received_events_url":"https://api.github.com/users/mengxr/received_events","type":"User","site_admin":false},"body":"better merge `.mapValues` to the line below.","created_at":"2014-07-09T05:47:24Z","updated_at":"2014-07-09T05:47:24Z","html_url":"https://github.com/apache/spark/pull/1025#discussion_r14694378","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/1025","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/14694378"},"html":{"href":"https://github.com/apache/spark/pull/1025#discussion_r14694378"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/1025"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/1025","id":16908302,"html_url":"https://github.com/apache/spark/pull/1025","diff_url":"https://github.com/apache/spark/pull/1025.diff","patch_url":"https://github.com/apache/spark/pull/1025.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/1025","number":1025,"state":"open","title":"[SPARK-2082] stratified sampling in PairRDDFunctions that guarantees exact sample size","user":{"login":"dorx","id":724072,"avatar_url":"https://avatars.githubusercontent.com/u/724072?","gravatar_id":"9fd1653ab2e3e8dfe69e5e824592dcaa","url":"https://api.github.com/users/dorx","html_url":"https://github.com/dorx","followers_url":"https://api.github.com/users/dorx/followers","following_url":"https://api.github.com/users/dorx/following{/other_user}","gists_url":"https://api.github.com/users/dorx/gists{/gist_id}","starred_url":"https://api.github.com/users/dorx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dorx/subscriptions","organizations_url":"https://api.github.com/users/dorx/orgs","repos_url":"https://api.github.com/users/dorx/repos","events_url":"https://api.github.com/users/dorx/events{/privacy}","received_events_url":"https://api.github.com/users/dorx/received_events","type":"User","site_admin":false},"body":"Implemented stratified sampling that guarantees exact sample size using ScaRSR with two passes over the RDD for sampling without replacement and three passes for sampling with replacement.","created_at":"2014-06-09T21:06:47Z","updated_at":"2014-07-09T05:47:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a1195035c507716dd08026608c0d260030c444c5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/1025/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/1025/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/1025/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/a10e68dd9c23b0fc1f25effd9ccd0ac3e7299206","head":{"label":"dorx:stratified","ref":"stratified","sha":"a10e68dd9c23b0fc1f25effd9ccd0ac3e7299206","user":{"login":"dorx","id":724072,"avatar_url":"https://avatars.githubusercontent.com/u/724072?","gravatar_id":"9fd1653ab2e3e8dfe69e5e824592dcaa","url":"https://api.github.com/users/dorx","html_url":"https://github.com/dorx","followers_url":"https://api.github.com/users/dorx/followers","following_url":"https://api.github.com/users/dorx/following{/other_user}","gists_url":"https://api.github.com/users/dorx/gists{/gist_id}","starred_url":"https://api.github.com/users/dorx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dorx/subscriptions","organizations_url":"https://api.github.com/users/dorx/orgs","repos_url":"https://api.github.com/users/dorx/repos","events_url":"https://api.github.com/users/dorx/events{/privacy}","received_events_url":"https://api.github.com/users/dorx/received_events","type":"User","site_admin":false},"repo":{"id":20234878,"name":"spark","full_name":"dorx/spark","owner":{"login":"dorx","id":724072,"avatar_url":"https://avatars.githubusercontent.com/u/724072?","gravatar_id":"9fd1653ab2e3e8dfe69e5e824592dcaa","url":"https://api.github.com/users/dorx","html_url":"https://github.com/dorx","followers_url":"https://api.github.com/users/dorx/followers","following_url":"https://api.github.com/users/dorx/following{/other_user}","gists_url":"https://api.github.com/users/dorx/gists{/gist_id}","starred_url":"https://api.github.com/users/dorx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dorx/subscriptions","organizations_url":"https://api.github.com/users/dorx/orgs","repos_url":"https://api.github.com/users/dorx/repos","events_url":"https://api.github.com/users/dorx/events{/privacy}","received_events_url":"https://api.github.com/users/dorx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dorx/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/dorx/spark","forks_url":"https://api.github.com/repos/dorx/spark/forks","keys_url":"https://api.github.com/repos/dorx/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dorx/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dorx/spark/teams","hooks_url":"https://api.github.com/repos/dorx/spark/hooks","issue_events_url":"https://api.github.com/repos/dorx/spark/issues/events{/number}","events_url":"https://api.github.com/repos/dorx/spark/events","assignees_url":"https://api.github.com/repos/dorx/spark/assignees{/user}","branches_url":"https://api.github.com/repos/dorx/spark/branches{/branch}","tags_url":"https://api.github.com/repos/dorx/spark/tags","blobs_url":"https://api.github.com/repos/dorx/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dorx/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dorx/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/dorx/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dorx/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/dorx/spark/languages","stargazers_url":"https://api.github.com/repos/dorx/spark/stargazers","contributors_url":"https://api.github.com/repos/dorx/spark/contributors","subscribers_url":"https://api.github.com/repos/dorx/spark/subscribers","subscription_url":"https://api.github.com/repos/dorx/spark/subscription","commits_url":"https://api.github.com/repos/dorx/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/dorx/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/dorx/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/dorx/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/dorx/spark/contents/{+path}","compare_url":"https://api.github.com/repos/dorx/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dorx/spark/merges","archive_url":"https://api.github.com/repos/dorx/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dorx/spark/downloads","issues_url":"https://api.github.com/repos/dorx/spark/issues{/number}","pulls_url":"https://api.github.com/repos/dorx/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/dorx/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/dorx/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dorx/spark/labels{/name}","releases_url":"https://api.github.com/repos/dorx/spark/releases{/id}","created_at":"2014-05-27T20:44:20Z","updated_at":"2014-06-27T17:49:22Z","pushed_at":"2014-07-09T01:09:21Z","git_url":"git://github.com/dorx/spark.git","ssh_url":"git@github.com:dorx/spark.git","clone_url":"https://github.com/dorx/spark.git","svn_url":"https://github.com/dorx/spark","homepage":null,"size":71578,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"e6f7bfcfbf6aff7a9f8cd8e0a2166d0bf62b0912","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?","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":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?","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/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}","created_at":"2014-02-25T08:00:08Z","updated_at":"2014-07-09T04:05:41Z","pushed_at":"2014-07-09T02:18:23Z","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":2117500,"stargazers_count":786,"watchers_count":786,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":793,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":224,"forks":793,"open_issues":224,"watchers":786,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/1025"},"html":{"href":"https://github.com/apache/spark/pull/1025"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/1025"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/1025/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/1025/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/1025/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/a10e68dd9c23b0fc1f25effd9ccd0ac3e7299206"}}}}