shahidki31 commented on a change in pull request #32734:
URL: https://github.com/apache/spark/pull/32734#discussion_r643412180



##########
File path: 
mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed/RowMatrix.scala
##########
@@ -439,7 +439,8 @@ class RowMatrix @Since("1.0.0") (
       "  Cannot compute the covariance of a RowMatrix with <= 1 row.")
     val mean = Vectors.fromML(summary.mean)
 
-    if (rows.first().isInstanceOf[DenseVector]) {
+    // If all the rows are sparse vectors, then compute based on 
`computeSparseVectorCovariance`.
+    if (!rows.filter(_.isInstanceOf[DenseVector]).isEmpty()) {

Review comment:
       I think `rows` is an RDD of Vector. There is no `exists` defined in the 
RDD class. Please correct me if I am wrong.
   
   Also in the above step, we do expensive operations will computing summary, 
so not sure this filter is expense comparatively.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to