GitHub user shahidki31 opened a pull request:

    https://github.com/apache/spark/pull/21740

    [SPARK-18230][MLLib]Throw better exception,for a non-existing user/product

    When invoking MatrixFactorizationModel.recommendProducts(Int, Int) with a 
non-existing user, a java.util.NoSuchElementException is thrown:
    
    > java.util.NoSuchElementException: next on empty iterator
        at scala.collection.Iterator$$anon$2.next(Iterator.scala:39)
        at scala.collection.Iterator$$anon$2.next(Iterator.scala:37)
        at 
scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:63)
        at scala.collection.IterableLike$class.head(IterableLike.scala:107)
        at 
scala.collection.mutable.WrappedArray.scala$collection$IndexedSeqOptimized$$super$head(WrappedArray.scala:35)
        at 
scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:126)
        at scala.collection.mutable.WrappedArray.head(WrappedArray.scala:35)
        at 
org.apache.spark.mllib.recommendation.MatrixFactorizationModel.recommendProducts(MatrixFactorizationModel.scala:169)
    
    ## What changes were proposed in this pull request?
    Throw a better exception, like "user-id/product-id doesn't found in the 
model", for a non-existent user/product
    
    ## How was this patch tested?
    Added UT


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/shahidki31/spark checkInvalidUserProduct

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/21740.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #21740
    
----
commit c8a4e9b1cda712ad8fc98ffc916b70d2a9495502
Author: Shahid <shahidki31@...>
Date:   2018-07-09T18:06:39Z

    [SPARK-18230][MLLib]Throw better exception, if the user/product doesn't 
exist

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to