Skip to content

Commit f1069b8

Browse files
zsxwingrxin
authored andcommittedNov 21, 2014
[SPARK-4472][Shell] Print "Spark context available as sc." only when SparkContext is created...
... successfully It's weird that printing "Spark context available as sc" when creating SparkContext unsuccessfully. Author: zsxwing <[email protected]> Closes apache#3341 from zsxwing/SPARK-4472 and squashes the following commits: 4850093 [zsxwing] Print "Spark context available as sc." only when SparkContext is created successfully
1 parent 28fdc6f commit f1069b8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
 

‎repl/scala-2.10/src/main/scala/org/apache/spark/repl/SparkILoopInit.scala

+5-2
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ trait SparkILoopInit {
121121
def initializeSpark() {
122122
intp.beQuietDuring {
123123
command("""
124-
@transient val sc = org.apache.spark.repl.Main.interp.createSparkContext();
124+
@transient val sc = {
125+
val _sc = org.apache.spark.repl.Main.interp.createSparkContext()
126+
println("Spark context available as sc.")
127+
_sc
128+
}
125129
""")
126130
command("import org.apache.spark.SparkContext._")
127131
}
128-
echo("Spark context available as sc.")
129132
}
130133

131134
// code to be executed only after the interpreter is initialized

‎repl/scala-2.11/src/main/scala/org/apache/spark/repl/SparkILoop.scala

+5-2
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ class SparkILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
6161
def initializeSpark() {
6262
intp.beQuietDuring {
6363
command( """
64-
@transient val sc = org.apache.spark.repl.Main.createSparkContext();
64+
@transient val sc = {
65+
val _sc = org.apache.spark.repl.Main.createSparkContext()
66+
println("Spark context available as sc.")
67+
_sc
68+
}
6569
""")
6670
command("import org.apache.spark.SparkContext._")
6771
}
68-
echo("Spark context available as sc.")
6972
}
7073

7174
/** Print a welcome message */

0 commit comments

Comments
 (0)
Please sign in to comment.