Search in sources :

Example 1 with SparkInterpreterBuilder

use of com.thinkbiganalytics.spark.SparkInterpreterBuilder in project kylo by Teradata.

the class SparkScriptEngine method getInterpreter.

/**
 * Gets the Spark REPL interface to be used.
 *
 * @return the interpreter
 */
@Nonnull
private IMain getInterpreter() {
    if (this.interpreter == null) {
        // Determine engine settings
        final Settings settings = getSettings();
        // Initialize engine
        final ClassLoader parentClassLoader = getClass().getClassLoader();
        final SparkInterpreterBuilder b = this.builder.withSettings(settings).withPrintWriter(getPrintWriter()).withClassLoader(parentClassLoader);
        final IMain interpreter = b.newInstance();
        interpreter.setContextClassLoader();
        interpreter.initializeSynchronous();
        // Setup environment
        final scala.collection.immutable.List<String> empty = JavaConversions.asScalaBuffer(new ArrayList<String>()).toList();
        final Results.Result result = interpreter.bind("engine", SparkScriptEngine.class.getName(), this, empty);
        if (result instanceof Results.Error$) {
            throw new IllegalStateException("Failed to initialize interpreter");
        }
        this.interpreter = interpreter;
    }
    return this.interpreter;
}
Also used : ArrayList(java.util.ArrayList) IMain(scala.tools.nsc.interpreter.IMain) SparkInterpreterBuilder(com.thinkbiganalytics.spark.SparkInterpreterBuilder) Results(scala.tools.nsc.interpreter.Results) URLClassLoader(java.net.URLClassLoader) Settings(scala.tools.nsc.Settings) Nonnull(javax.annotation.Nonnull)

Aggregations

SparkInterpreterBuilder (com.thinkbiganalytics.spark.SparkInterpreterBuilder)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 Settings (scala.tools.nsc.Settings)1 IMain (scala.tools.nsc.interpreter.IMain)1 Results (scala.tools.nsc.interpreter.Results)1