zhengruifeng opened a new pull request, #58122: URL: https://github.com/apache/spark/pull/58122
### What changes were proposed in this pull request? This PR updates mllib KMeans distance measure implementations to use singleton objects instead of allocating a new instance when decoding the configured distance measure. It also changes KMeansModel's decoded distanceMeasureInstance from a transient lazy val to a private val, and updates internal/test call sites to reference the Euclidean distance measure singleton directly. ### Why are the changes needed? This is part of SPARK-58584. KMeans only has stateless distance measure implementations, so allocating per decode is unnecessary. Reusing singleton instances avoids per-model helper allocation and lets KMeansModel hold the decoded helper directly. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - build/sbt -java-home /usr/lib/jvm/java-17-openjdk-amd64 mllib/compile - build/sbt -java-home /usr/lib/jvm/java-17-openjdk-amd64 'mllib/testOnly org.apache.spark.mllib.clustering.KMeansSuite' ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
