Github user hhbyyh commented on a diff in the pull request:
https://github.com/apache/spark/pull/10146#discussion_r49408306
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/stat/test/ChiSqTest.scala ---
@@ -109,7 +109,9 @@ private[stat] object ChiSqTest extends Logging {
}
i += 1
distinctLabels += label
- features.toArray.view.zipWithIndex.slice(startCol, endCol).map {
case (feature, col) =>
+ val featureArray = features.toArray
+ (startCol until endCol).map { col =>
+ val feature = featureArray(col)
--- End diff --
@jkbradley I changed it to invoking toBreeze directly. I ran some test on
local.
```
val sv = new SparseVector(100000, Array(1), Array(2.5))
var t = 0.0
{
val ts = System.nanoTime()
val arr = sv.toArray
for(i <- 0 to 10000){
t = arr(i)
}
println(System.nanoTime() - ts)
}
{
val ts = System.nanoTime()
for(i <- 0 to 10000){
t = sv(i)
}
println(System.nanoTime() - ts)
}
{
val ts = System.nanoTime()
val brz = sv.toBreeze
for(i <- 0 to 10000){
t = brz(i)
}
println(System.nanoTime() - ts)
}
```
gives
3405342
520367839
4870954
Let me know how do you think of it.
---
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]