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;
}
Aggregations