aboutsummaryrefslogtreecommitdiff
path: root/repl
diff options
context:
space:
mode:
authorMatei Zaharia <matei@eecs.berkeley.edu>2011-05-31 22:05:24 -0700
committerMatei Zaharia <matei@eecs.berkeley.edu>2011-05-31 22:05:24 -0700
commit73975d7491bc413b5f19022ff1df92d6e0ce3c24 (patch)
tree66e56e310a73faf1560d36f743a6976e5393c46c /repl
parentd52660c96925291eb7b2ce32cb6ad72dc50eade7 (diff)
downloadspark-73975d7491bc413b5f19022ff1df92d6e0ce3c24.tar.gz
spark-73975d7491bc413b5f19022ff1df92d6e0ce3c24.tar.bz2
spark-73975d7491bc413b5f19022ff1df92d6e0ce3c24.zip
Further fixes to interpreter (adding in some code generation changes I
missed before and setting SparkEnv properly on the threads that execute each line in the 2.9 interpreter).
Diffstat (limited to 'repl')
-rw-r--r--repl/src/main/scala/spark/repl/SparkILoop.scala4
-rw-r--r--repl/src/main/scala/spark/repl/SparkIMain.scala11
-rw-r--r--repl/src/main/scala/spark/repl/SparkImports.scala4
3 files changed, 15 insertions, 4 deletions
diff --git a/repl/src/main/scala/spark/repl/SparkILoop.scala b/repl/src/main/scala/spark/repl/SparkILoop.scala
index bfbc66ebdd..aec398b965 100644
--- a/repl/src/main/scala/spark/repl/SparkILoop.scala
+++ b/repl/src/main/scala/spark/repl/SparkILoop.scala
@@ -842,6 +842,9 @@ class SparkILoop(in0: Option[BufferedReader], val out: PrintWriter, val master:
}
def process(settings: Settings): Boolean = {
+ printWelcome()
+ echo("Initializing interpreter...")
+
this.settings = settings
createInterpreter()
@@ -856,7 +859,6 @@ class SparkILoop(in0: Option[BufferedReader], val out: PrintWriter, val master:
if (intp.reporter.hasErrors)
return false
- printWelcome()
try {
// this is about the illusion of snappiness. We call initialize()
// which spins off a separate thread, then print the prompt and try
diff --git a/repl/src/main/scala/spark/repl/SparkIMain.scala b/repl/src/main/scala/spark/repl/SparkIMain.scala
index 49d0a27030..14e6eb3455 100644
--- a/repl/src/main/scala/spark/repl/SparkIMain.scala
+++ b/repl/src/main/scala/spark/repl/SparkIMain.scala
@@ -29,6 +29,7 @@ import SparkIMain._
import spark.HttpServer
import spark.Utils
+import spark.SparkEnv
/** An interpreter for Scala code.
*
@@ -879,7 +880,15 @@ class SparkIMain(val settings: Settings, protected val out: PrintWriter) extends
}
try {
- val execution = lineManager.set(originalLine)(lineRep call "$export")
+ val execution = lineManager.set(originalLine) {
+ // MATEI: set the right SparkEnv for our SparkContext, because
+ // this execution will happen in a separate thread
+ val sc = spark.repl.Main.interp.sparkContext
+ if (sc != null && sc.env != null)
+ SparkEnv.set(sc.env)
+ // Execute the line
+ lineRep call "$export"
+ }
execution.await()
execution.state match {
diff --git a/repl/src/main/scala/spark/repl/SparkImports.scala b/repl/src/main/scala/spark/repl/SparkImports.scala
index bd28395f2e..6ccd3cf1f0 100644
--- a/repl/src/main/scala/spark/repl/SparkImports.scala
+++ b/repl/src/main/scala/spark/repl/SparkImports.scala
@@ -144,8 +144,8 @@ trait SparkImports {
// add code for a new object to hold some imports
def addWrapper() {
val impname = nme.INTERPRETER_IMPORT_WRAPPER
- code append "object %s {\n".format(impname)
- trailingBraces append "}\n"
+ code append "class %sC extends Serializable {\n".format(impname)
+ trailingBraces append "}\nval " + impname + " = new " + impname + "C;\n"
accessPath append ("." + impname)
currentImps.clear