zhengruifeng commented on a change in pull request #25324: [SPARK-21481][ML][FOLLOWUP] HashingTF Cleanup and Tiny Optimizations URL: https://github.com/apache/spark/pull/25324#discussion_r311330089
########## File path: mllib/src/main/scala/org/apache/spark/ml/feature/HashingTF.scala ########## @@ -100,19 +100,26 @@ class HashingTF @Since("1.4.0") (@Since("1.4.0") override val uid: String) @Since("2.0.0") override def transform(dataset: Dataset[_]): DataFrame = { val outputSchema = transformSchema(dataset.schema) - val hashUDF = udf { terms: Seq[_] => - val numOfFeatures = $(numFeatures) - val isBinary = $(binary) - val termFrequencies = mutable.HashMap.empty[Int, Double].withDefaultValue(0.0) - terms.foreach { term => - val i = indexOf(term) - if (isBinary) { + val localNumFeatures = $(numFeatures) + + val hashUDF = if ($(binary)) { Review comment: ok, I misunderstood the comments ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org