You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by pw...@apache.org on 2014/07/22 09:38:34 UTC

git commit: [SPARK-2452] Create a new valid for each instead of using lineId.

Repository: spark
Updated Branches:
  refs/heads/master 5d16d5bbf -> 81fec9922


[SPARK-2452] Create a new valid for each  instead of using lineId.

Author: Prashant Sharma <pr...@apache.org>

Closes #1441 from ScrapCodes/SPARK-2452/multi-statement and squashes the following commits:

26c5c72 [Prashant Sharma] Added a test case.
7e8d28d [Prashant Sharma] SPARK-2452, create a new valid for each  instead of using lineId, because Line ids can be same sometimes.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/81fec992
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/81fec992
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/81fec992

Branch: refs/heads/master
Commit: 81fec9922c5a1a44e086fba450c3eea03cddce63
Parents: 5d16d5b
Author: Prashant Sharma <pr...@apache.org>
Authored: Tue Jul 22 00:38:26 2014 -0700
Committer: Patrick Wendell <pw...@gmail.com>
Committed: Tue Jul 22 00:38:26 2014 -0700

----------------------------------------------------------------------
 .../main/scala/org/apache/spark/repl/SparkImports.scala  |  8 +++++++-
 .../src/test/scala/org/apache/spark/repl/ReplSuite.scala | 11 ++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/81fec992/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
----------------------------------------------------------------------
diff --git a/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala b/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
index bce5c74..9099e05 100644
--- a/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
+++ b/repl/src/main/scala/org/apache/spark/repl/SparkImports.scala
@@ -197,7 +197,7 @@ trait SparkImports {
           for (imv <- x.definedNames) {
             if (currentImps contains imv) addWrapper()
             val objName = req.lineRep.readPath
-            val valName = "$VAL" + req.lineRep.lineId
+            val valName = "$VAL" + newValId()
 
             if(!code.toString.endsWith(".`" + imv + "`;\n")) { // Which means already imported
                 code.append("val " + valName + " = " + objName + ".INSTANCE;\n")
@@ -222,4 +222,10 @@ trait SparkImports {
   private def membersAtPickler(sym: Symbol): List[Symbol] =
     beforePickler(sym.info.nonPrivateMembers.toList)
 
+  private var curValId = 0
+
+  private def newValId(): Int = {
+    curValId += 1
+    curValId
+  }
 }

http://git-wip-us.apache.org/repos/asf/spark/blob/81fec992/repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
----------------------------------------------------------------------
diff --git a/repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala b/repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
index f2aa42d..e2d8d5f 100644
--- a/repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
+++ b/repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
@@ -235,7 +235,7 @@ class ReplSuite extends FunSuite {
     assertContains("res4: Array[Int] = Array(0, 0, 0, 0, 0)", output)
   }
 
-  test("SPARK-1199-simple-reproduce") {
+  test("SPARK-1199 two instances of same class don't type check.") {
     val output = runInterpreter("local-cluster[1,1,512]",
       """
         |case class Sum(exp: String, exp2: String)
@@ -247,6 +247,15 @@ class ReplSuite extends FunSuite {
     assertDoesNotContain("Exception", output)
   }
 
+  test("SPARK-2452 compound statements.") {
+    val output = runInterpreter("local",
+      """
+        |val x = 4 ; def f() = x
+        |f()
+      """.stripMargin)
+    assertDoesNotContain("error:", output)
+    assertDoesNotContain("Exception", output)
+  }
   if (System.getenv("MESOS_NATIVE_LIBRARY") != null) {
     test("running on Mesos") {
       val output = runInterpreter("localquiet",