Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/661#discussion_r12311400
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala
---
@@ -136,7 +136,7 @@ object Vectors {
new DenseVector(v.toArray) // Can't use underlying array
directly, so make a new one
}
case v: BSV[Double] =>
- new SparseVector(v.length, v.index, v.data)
+ new SparseVector(v.length, v.index.slice(0, v.used),
v.data.slice(0, v.used))
--- End diff --
`slice` allocates a new array even when `v.used == v.index.length`. Could
you check `v.used == v.index.length` first?
---
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.
---