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

    https://github.com/apache/spark/pull/4217#discussion_r23585794
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala 
---
    @@ -371,17 +371,19 @@ object Vectors {
               squaredDistance += score * score
             }
     
    -      case (v1: SparseVector, v2: DenseVector) if v1.indices.length / 
v1.size < 0.5 =>
    +      case (v1: SparseVector, v2: DenseVector) =>
             squaredDistance = sqdist(v1, v2)
     
    -      case (v1: DenseVector, v2: SparseVector) if v2.indices.length / 
v2.size < 0.5 =>
    +      case (v1: DenseVector, v2: SparseVector) =>
             squaredDistance = sqdist(v2, v1)
     
    -      // When a SparseVector is approximately dense, we treat it as a 
DenseVector
           case (v1, v2) =>
    --- End diff --
    
    I would recommend using 
    
    ~~~
    case (DenseVector(vv1), DenseVector(vv2)) =>
      var i = 0
      val sz = vv1.size
      while (i < sz) {
        ...
      }
    case _ =>
      // throw exception
    ~~~


---
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.
---

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

Reply via email to