You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by techaddict <gi...@git.apache.org> on 2014/04/23 10:07:11 UTC

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

GitHub user techaddict opened a pull request:

    https://github.com/apache/spark/pull/503

    [Fix #79] Replace Breakable For Loops By While Loops

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/techaddict/spark fix-79

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/503.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #503
    
----
commit 0a6d8e9cc094b30c6b08c06b852db5b8e6afa640
Author: Sandeep <sa...@techaddict.me>
Date:   2014-04-23T07:45:20Z

    Breakable for loop to While loop

commit 07a4f6bd7bb81dc837da0cbc40792af94665c39c
Author: Sandeep <sa...@techaddict.me>
Date:   2014-04-23T07:48:12Z

    for loop to While loop

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by techaddict <gi...@git.apache.org>.
Github user techaddict commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41244496
  
    @rxin  all suggested changes done, tests passed


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by techaddict <gi...@git.apache.org>.
Github user techaddict commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41240253
  
    @mateiz  retest this please, I think failure is due to some other PR, as these changes have nothing to do with Streaming.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41242555
  
    Jenkins, retest this please.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41244343
  
    Merged build finished. All automated tests passed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41134871
  
    Can one of the admins verify this patch?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41229116
  
    
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14406/


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/503


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41223389
  
    Merged build started. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41229115
  
    Merged build finished. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41242711
  
    Merged build started. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by mateiz <gi...@git.apache.org>.
Github user mateiz commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41223350
  
    Jenkins, test this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41223383
  
     Merged build triggered. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/503#discussion_r11935731
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala ---
    @@ -82,32 +80,32 @@ class DecisionTree (private val strategy: Strategy) extends Serializable with Lo
          * still survived the filters of the parent nodes.
          */
     
    -    // TODO: Convert for loop to while loop
    -    breakable {
    -      for (level <- 0 until maxDepth) {
    -
    -        logDebug("#####################################")
    -        logDebug("level = " + level)
    -        logDebug("#####################################")
    -
    -        // Find best split for all nodes at a level.
    -        val splitsStatsForLevel = DecisionTree.findBestSplits(input, parentImpurities, strategy,
    -          level, filters, splits, bins)
    -
    -        for ((nodeSplitStats, index) <- splitsStatsForLevel.view.zipWithIndex) {
    -          // Extract info for nodes at the current level.
    -          extractNodeInfo(nodeSplitStats, level, index, nodes)
    -          // Extract info for nodes at the next lower level.
    -          extractInfoForLowerLevels(level, index, maxDepth, nodeSplitStats, parentImpurities,
    -            filters)
    -          logDebug("final best split = " + nodeSplitStats._1)
    -        }
    -        require(scala.math.pow(2, level) == splitsStatsForLevel.length)
    -        // Check whether all the nodes at the current level at leaves.
    -        val allLeaf = splitsStatsForLevel.forall(_._2.gain <= 0)
    -        logDebug("all leaf = " + allLeaf)
    -        if (allLeaf) break // no more tree construction
    +    var level = 0
    +    var break = false
    +    while (level < maxDepth && !break) {
    +
    +      logDebug("#####################################")
    +      logDebug("level = " + level)
    +      logDebug("#####################################")
    +
    +      // Find best split for all nodes at a level.
    +      val splitsStatsForLevel = DecisionTree.findBestSplits(input, parentImpurities, strategy,
    +        level, filters, splits, bins)
    +
    +      for ((nodeSplitStats, index) <- splitsStatsForLevel.view.zipWithIndex) {
    +        // Extract info for nodes at the current level.
    +        extractNodeInfo(nodeSplitStats, level, index, nodes)
    +        // Extract info for nodes at the next lower level.
    +        extractInfoForLowerLevels(level, index, maxDepth, nodeSplitStats, parentImpurities,
    +          filters)
    +        logDebug("final best split = " + nodeSplitStats._1)
           }
    +      require(scala.math.pow(2, level) == splitsStatsForLevel.length)
    +      // Check whether all the nodes at the current level at leaves.
    +      val allLeaf = splitsStatsForLevel.forall(_._2.gain <= 0)
    +      logDebug("all leaf = " + allLeaf)
    +      if (allLeaf) break = true // no more tree construction
    --- End diff --
    
    per Spark style guide, can you change this to include curly braces, e.g.
    ```scala
    if (allLeaf) {
      break = true
    } else {
      level += 1
    }
    ```
    
    Thanks.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41244771
  
    Thanks. I've merged this.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41242705
  
     Merged build triggered. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [Fix #79] Replace Breakable For Loops By While...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/503#issuecomment-41244344
  
    All automated tests passed.
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14424/


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---