forked from apache/zeppelin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4c378b
commit f2bdd5c
Showing
52 changed files
with
353 additions
and
602 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
spark/src/main/scala/com/nflabs/zeppelin/spark/ReflectSparkILoop.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.nflabs.zeppelin.spark | ||
|
||
import scala.tools.nsc._ | ||
import scala.tools.nsc.interpreter._ | ||
import org.apache.spark.repl.SparkILoop | ||
import org.apache.spark.repl.SparkIMain | ||
import org.apache.spark.util.Utils | ||
import java.io.BufferedReader | ||
import scala.tools.nsc.util.{ ClassPath, Exceptional, stringFromWriter, stringFromStream } | ||
|
||
|
||
class ReflectSparkILoop(in0: Option[BufferedReader], override protected val out: JPrintWriter, override val master: Option[String]) | ||
extends SparkILoop(in0, out, master) { | ||
def this(in0: BufferedReader, out: JPrintWriter, master: String) = this(Some(in0), out, Some(master)) | ||
def this(in0: BufferedReader, out: JPrintWriter) = this(Some(in0), out, None) | ||
def this() = this(None, new JPrintWriter(Console.out, true), None) | ||
|
||
|
||
class ReflectSparkILoopInterpreter extends ReflectSparkIMain(settings, out) { | ||
outer => | ||
|
||
override lazy val formatting = new Formatting { | ||
def prompt = ReflectSparkILoop.this.prompt | ||
} | ||
override protected def parentClassLoader = SparkHelper.explicitParentLoader(settings).getOrElse(classOf[SparkILoop].getClassLoader) | ||
} | ||
|
||
/** Create a new interpreter. */ | ||
override def createInterpreter() { | ||
require(settings != null) | ||
|
||
if (addedClasspath != "") settings.classpath.append(addedClasspath) | ||
// work around for Scala bug | ||
val totalClassPath = SparkILoop.getAddedJars.foldLeft( | ||
settings.classpath.value)((l, r) => ClassPath.join(l, r)) | ||
this.settings.classpath.value = totalClassPath | ||
|
||
intp = new ReflectSparkILoopInterpreter | ||
} | ||
|
||
/** Create a new interpreter. */ | ||
def createReflectInterpreter(settings : Settings) : SparkIMain = { | ||
require(settings != null) | ||
|
||
if (addedClasspath != "") settings.classpath.append(addedClasspath) | ||
// work around for Scala bug | ||
val totalClassPath = SparkILoop.getAddedJars.foldLeft( | ||
settings.classpath.value)((l, r) => ClassPath.join(l, r)) | ||
this.settings.classpath.value = totalClassPath | ||
|
||
intp = new ReflectSparkILoopInterpreter | ||
intp | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
spark/src/main/scala/com/nflabs/zeppelin/spark/ReflectSparkIMain.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.nflabs.zeppelin.spark | ||
|
||
import scala.tools.nsc._ | ||
import scala.tools.nsc.interpreter._ | ||
import reporters._ | ||
import org.apache.spark.repl.SparkIMain | ||
import scala.tools.reflect._ | ||
class ReflectSparkIMain(initialSettings: Settings, override val out: JPrintWriter) extends SparkIMain(initialSettings, out) { | ||
|
||
override def newCompiler(settings: Settings, reporter: Reporter): ReplGlobal = { | ||
settings.outputDirs setSingleOutput virtualDirectory | ||
settings.exposeEmptyPackage.value = true | ||
new ReflectGlobal(settings, reporter, classLoader) with ReplGlobal { | ||
override def toString: String = "<global>" | ||
} | ||
} | ||
} |
Oops, something went wrong.