Github user shimamoto commented on a diff in the pull request:

    
https://github.com/apache/incubator-predictionio/pull/425#discussion_r135175043
  
    --- Diff: 
core/src/main/scala/org/apache/predictionio/controller/PAlgorithm.scala ---
    @@ -115,15 +115,12 @@ abstract class PAlgorithm[PD, M, Q, P]
         algoParams: Params,
         bm: Any): Any = {
         val m = bm.asInstanceOf[M]
    -    if (m.isInstanceOf[PersistentModel[_]]) {
    -      if (m.asInstanceOf[PersistentModel[Params]].save(
    -        modelId, algoParams, sc)) {
    -        PersistentModelManifest(className = m.getClass.getName)
    -      } else {
    -        ()
    -      }
    -    } else {
    -      ()
    +    m match {
    +      case m: PersistentModel[Params] @unchecked =>
    +        if(m.save(modelId, algoParams, sc)){
    +          PersistentModelManifest(className = m.getClass.getName)
    +        } else ()
    +      case _ => ()
    --- End diff --
    
    This code will be simpler to read by joining the if guard with the case 
statement.
    
    ```scala
    case m: PersistentModel[Params] @unchecked
      if m.save(modelId, algoParams, sc) => ...
    case _ => ...
    ```
    
    But it looks this behavior differs from other algorithms (LAlgorithm.scala 
and P2LAlgorithm.scala). Which is correct?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to