Github user karlhigley commented on a diff in the pull request:
https://github.com/apache/spark/pull/9843#discussion_r46017996
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/feature/IDF.scala ---
@@ -211,14 +213,17 @@ private object IDFModel {
val n = v.size
v match {
case SparseVector(size, indices, values) =>
+ val newElements = new ArrayBuffer[(Int, Double)]
val nnz = indices.size
- val newValues = new Array[Double](nnz)
var k = 0
while (k < nnz) {
- newValues(k) = values(k) * idf(indices(k))
+ val newValue = values(k) * idf(indices(k))
--- End diff --
As the diff shows, the existing code is already calling `idf(indices(k))`.
That call may indeed be expensive and represent a potential optimization, but
it's distinct from the problem this PR is intended to address. Seems like there
might be room for a second JIRA/PR to handle the issue you identified.
---
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]