{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/202545740","pull_request_review_id":137269670,"id":202545740,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMjU0NTc0MA==","diff_hunk":"@@ -165,7 +183,7 @@ class MatrixFactorizationModel @Since(\"0.8.0\") (\n    */\n   @Since(\"1.1.0\")\n   def recommendProducts(user: Int, num: Int): Array[Rating] =","path":"mllib/src/main/scala/org/apache/spark/mllib/recommendation/MatrixFactorizationModel.scala","position":35,"original_position":35,"commit_id":"b07e07e0023ba1d25bd84f6f627bb77ba1d1353e","original_commit_id":"b07e07e0023ba1d25bd84f6f627bb77ba1d1353e","user":{"login":"srowen","id":822522,"node_id":"MDQ6VXNlcjgyMjUyMg==","avatar_url":"https://avatars0.githubusercontent.com/u/822522?v=4","gravatar_id":"","url":"https://api.github.com/users/srowen","html_url":"https://github.com/srowen","followers_url":"https://api.github.com/users/srowen/followers","following_url":"https://api.github.com/users/srowen/following{/other_user}","gists_url":"https://api.github.com/users/srowen/gists{/gist_id}","starred_url":"https://api.github.com/users/srowen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srowen/subscriptions","organizations_url":"https://api.github.com/users/srowen/orgs","repos_url":"https://api.github.com/users/srowen/repos","events_url":"https://api.github.com/users/srowen/events{/privacy}","received_events_url":"https://api.github.com/users/srowen/received_events","type":"User","site_admin":false},"body":"Returning `Option` could be reasonable, but, I think the caller would end up giving up with an exception anyway. There isn't an obviously better thing to do.\r\n\r\nExceptions all behave as if unchecked in Scala and don't get expressed in method signatures in the byte code. `@throws` is really for Java compatibility where it's important for the Java language to express that a checked exception is thrown (it makes a compile-time difference in Java).\r\n\r\nThat's not necessary here, but scaladoc'ing exceptions like this is indeed a good idea.","created_at":"2018-07-15T15:10:08Z","updated_at":"2018-07-15T15:10:08Z","html_url":"https://github.com/apache/spark/pull/21740#discussion_r202545740","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/21740","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/202545740"},"html":{"href":"https://github.com/apache/spark/pull/21740#discussion_r202545740"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/21740"}},"in_reply_to_id":202542318},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/21740","id":200180565,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwMTgwNTY1","html_url":"https://github.com/apache/spark/pull/21740","diff_url":"https://github.com/apache/spark/pull/21740.diff","patch_url":"https://github.com/apache/spark/pull/21740.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/21740","number":21740,"state":"open","locked":false,"title":"[SPARK-18230][MLLib]Throw a better exception, if the user or product doesn't exist","user":{"login":"shahidki31","id":23054875,"node_id":"MDQ6VXNlcjIzMDU0ODc1","avatar_url":"https://avatars0.githubusercontent.com/u/23054875?v=4","gravatar_id":"","url":"https://api.github.com/users/shahidki31","html_url":"https://github.com/shahidki31","followers_url":"https://api.github.com/users/shahidki31/followers","following_url":"https://api.github.com/users/shahidki31/following{/other_user}","gists_url":"https://api.github.com/users/shahidki31/gists{/gist_id}","starred_url":"https://api.github.com/users/shahidki31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shahidki31/subscriptions","organizations_url":"https://api.github.com/users/shahidki31/orgs","repos_url":"https://api.github.com/users/shahidki31/repos","events_url":"https://api.github.com/users/shahidki31/events{/privacy}","received_events_url":"https://api.github.com/users/shahidki31/received_events","type":"User","site_admin":false},"body":"When invoking MatrixFactorizationModel.recommendProducts(Int, Int) with a non-existing user, a java.util.NoSuchElementException is thrown:\r\n\r\n> java.util.NoSuchElementException: next on empty iterator\r\n\tat scala.collection.Iterator$$anon$2.next(Iterator.scala:39)\r\n\tat scala.collection.Iterator$$anon$2.next(Iterator.scala:37)\r\n\tat scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:63)\r\n\tat scala.collection.IterableLike$class.head(IterableLike.scala:107)\r\n\tat scala.collection.mutable.WrappedArray.scala$collection$IndexedSeqOptimized$$super$head(WrappedArray.scala:35)\r\n\tat scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:126)\r\n\tat scala.collection.mutable.WrappedArray.head(WrappedArray.scala:35)\r\n\tat org.apache.spark.mllib.recommendation.MatrixFactorizationModel.recommendProducts(MatrixFactorizationModel.scala:169)\r\n\r\n## What changes were proposed in this pull request?\r\nThrow a better exception, like \"user-id/product-id doesn't found in the model\", for a non-existent user/product\r\n\r\n## How was this patch tested?\r\nAdded UT\r\n","created_at":"2018-07-09T18:19:54Z","updated_at":"2018-07-15T15:10:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db45a87c83055227c5902a8572782b6dbaf26cee","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/21740/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/21740/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/21740/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/b07e07e0023ba1d25bd84f6f627bb77ba1d1353e","head":{"label":"shahidki31:checkInvalidUserProduct","ref":"checkInvalidUserProduct","sha":"b07e07e0023ba1d25bd84f6f627bb77ba1d1353e","user":{"login":"shahidki31","id":23054875,"node_id":"MDQ6VXNlcjIzMDU0ODc1","avatar_url":"https://avatars0.githubusercontent.com/u/23054875?v=4","gravatar_id":"","url":"https://api.github.com/users/shahidki31","html_url":"https://github.com/shahidki31","followers_url":"https://api.github.com/users/shahidki31/followers","following_url":"https://api.github.com/users/shahidki31/following{/other_user}","gists_url":"https://api.github.com/users/shahidki31/gists{/gist_id}","starred_url":"https://api.github.com/users/shahidki31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shahidki31/subscriptions","organizations_url":"https://api.github.com/users/shahidki31/orgs","repos_url":"https://api.github.com/users/shahidki31/repos","events_url":"https://api.github.com/users/shahidki31/events{/privacy}","received_events_url":"https://api.github.com/users/shahidki31/received_events","type":"User","site_admin":false},"repo":{"id":104183844,"node_id":"MDEwOlJlcG9zaXRvcnkxMDQxODM4NDQ=","name":"spark","full_name":"shahidki31/spark","owner":{"login":"shahidki31","id":23054875,"node_id":"MDQ6VXNlcjIzMDU0ODc1","avatar_url":"https://avatars0.githubusercontent.com/u/23054875?v=4","gravatar_id":"","url":"https://api.github.com/users/shahidki31","html_url":"https://github.com/shahidki31","followers_url":"https://api.github.com/users/shahidki31/followers","following_url":"https://api.github.com/users/shahidki31/following{/other_user}","gists_url":"https://api.github.com/users/shahidki31/gists{/gist_id}","starred_url":"https://api.github.com/users/shahidki31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shahidki31/subscriptions","organizations_url":"https://api.github.com/users/shahidki31/orgs","repos_url":"https://api.github.com/users/shahidki31/repos","events_url":"https://api.github.com/users/shahidki31/events{/privacy}","received_events_url":"https://api.github.com/users/shahidki31/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shahidki31/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/shahidki31/spark","forks_url":"https://api.github.com/repos/shahidki31/spark/forks","keys_url":"https://api.github.com/repos/shahidki31/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shahidki31/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shahidki31/spark/teams","hooks_url":"https://api.github.com/repos/shahidki31/spark/hooks","issue_events_url":"https://api.github.com/repos/shahidki31/spark/issues/events{/number}","events_url":"https://api.github.com/repos/shahidki31/spark/events","assignees_url":"https://api.github.com/repos/shahidki31/spark/assignees{/user}","branches_url":"https://api.github.com/repos/shahidki31/spark/branches{/branch}","tags_url":"https://api.github.com/repos/shahidki31/spark/tags","blobs_url":"https://api.github.com/repos/shahidki31/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shahidki31/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shahidki31/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/shahidki31/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shahidki31/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/shahidki31/spark/languages","stargazers_url":"https://api.github.com/repos/shahidki31/spark/stargazers","contributors_url":"https://api.github.com/repos/shahidki31/spark/contributors","subscribers_url":"https://api.github.com/repos/shahidki31/spark/subscribers","subscription_url":"https://api.github.com/repos/shahidki31/spark/subscription","commits_url":"https://api.github.com/repos/shahidki31/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/shahidki31/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/shahidki31/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/shahidki31/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/shahidki31/spark/contents/{+path}","compare_url":"https://api.github.com/repos/shahidki31/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shahidki31/spark/merges","archive_url":"https://api.github.com/repos/shahidki31/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shahidki31/spark/downloads","issues_url":"https://api.github.com/repos/shahidki31/spark/issues{/number}","pulls_url":"https://api.github.com/repos/shahidki31/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/shahidki31/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/shahidki31/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shahidki31/spark/labels{/name}","releases_url":"https://api.github.com/repos/shahidki31/spark/releases{/id}","deployments_url":"https://api.github.com/repos/shahidki31/spark/deployments","created_at":"2017-09-20T07:51:04Z","updated_at":"2017-12-21T10:28:39Z","pushed_at":"2018-07-15T08:48:59Z","git_url":"git://github.com/shahidki31/spark.git","ssh_url":"git@github.com:shahidki31/spark.git","clone_url":"https://github.com/shahidki31/spark.git","svn_url":"https://github.com/shahidki31/spark","homepage":null,"size":271823,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"69993217fc4f5e5e41a297702389e86fe534dc2f","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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,"node_id":"MDEwOlJlcG9zaXRvcnkxNzE2NTY1OA==","name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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":"2018-07-15T15:01:49Z","pushed_at":"2018-07-15T14:54:10Z","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":276690,"stargazers_count":18073,"watchers_count":18073,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16422,"mirror_url":null,"archived":false,"open_issues_count":559,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":16422,"open_issues":559,"watchers":18073,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/21740"},"html":{"href":"https://github.com/apache/spark/pull/21740"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/21740"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/21740/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/21740/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/21740/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/b07e07e0023ba1d25bd84f6f627bb77ba1d1353e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"srowen"}}