This is an automated email from the ASF dual-hosted git repository.

zhengruifeng pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.x by this push:
     new 066949a5f2db [SPARK-58863][ML] Make tree leaf attribute uncached
066949a5f2db is described below

commit 066949a5f2db83bb2a3894cab53041a2c716f725
Author: Ruifeng Zheng <[email protected]>
AuthorDate: Thu Aug 20 09:01:32 2026 +0800

    [SPARK-58863][ML] Make tree leaf attribute uncached
    
    ### What changes were proposed in this pull request?
    
    Change tree model `leafAttr` from a `lazy val` to a `def`.
    
    `leafAttr` is a small metadata object derived from `numLeave`, and 
`numLeave` remains cached.
    
    ### Why are the changes needed?
    
    `leafAttr` is only used when building leaf-column schema metadata. Since 
the expensive leaf count
    is already cached by `numLeave`, caching the derived attribute itself is 
unnecessary.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Ran:
    
    ```
    build/sbt -java-home /usr/lib/jvm/java-17-openjdk-amd64 mllib/compile
    ```
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Codex (GPT-5)
    
    Closes #58109 from zhengruifeng/ml-leafattr-def.
    
    Authored-by: Ruifeng Zheng <[email protected]>
    Signed-off-by: Ruifeng Zheng <[email protected]>
    (cherry picked from commit 87a60559634f64a78e1ec3e46faa9468577be1a8)
    Signed-off-by: Ruifeng Zheng <[email protected]>
---
 mllib/src/main/scala/org/apache/spark/ml/tree/treeModels.scala | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mllib/src/main/scala/org/apache/spark/ml/tree/treeModels.scala 
b/mllib/src/main/scala/org/apache/spark/ml/tree/treeModels.scala
index 4e9fa89cbde9..fdc4110573ba 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/tree/treeModels.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/tree/treeModels.scala
@@ -98,7 +98,7 @@ private[spark] trait DecisionTreeModel {
   private[ml] lazy val numLeave: Int =
     leafIterator(rootNode).size
 
-  private[ml] lazy val leafAttr = {
+  private[ml] def leafAttr = {
     NominalAttribute.defaultAttr
       .withNumValues(numLeave)
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to