Github user codedeft commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2868#discussion_r19195671
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala ---
    @@ -553,7 +589,26 @@ object DecisionTree extends Serializable with Logging {
         // Finally, only best Splits for nodes are collected to driver to 
construct decision tree.
         val nodeToFeatures = getNodeToFeatures(treeToNodeToIndexInfo)
         val nodeToFeaturesBc = input.sparkContext.broadcast(nodeToFeatures)
    -    val nodeToBestSplits =
    +
    +    val partitionAggregates = if (useNodeIdCache) {
    +      input.zip(nodeIdCache.get.cur).mapPartitions { points =>
    +        // Construct a nodeStatsAggregators array to hold node aggregate 
stats,
    +        // each node will have a nodeStatsAggregator
    +        val nodeStatsAggregators = Array.tabulate(numNodes) { nodeIndex =>
    +          val featuresForNode = nodeToFeaturesBc.value.flatMap { 
nodeToFeatures =>
    +            Some(nodeToFeatures(nodeIndex))
    +          }
    +          new DTStatsAggregator(metadata, featuresForNode)
    +        }
    +
    +        // iterator all instances in current partition and update 
aggregate stats
    +        points.foreach(binSeqOpWithNodeIdCache(nodeStatsAggregators, _))
    --- End diff --
    
    Well, one requires zip and the other one doesn't,  so fundamentally changes 
the type of rows.
    
    Additionally, I think if we just branch out within mapPartitions, won't it 
unnecessarily serialize some things that are not used in one branch and not the 
other? E.g. it seems that binSeqOp itself becomes object and will be 
serialized, along with closure items.


---
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]

Reply via email to