Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6439 Optimalisation of scala test execution. #6454

Merged
merged 2 commits into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package com.twosigma.beakerx.scala.evaluator;

import com.google.inject.Provider;
import com.twosigma.beakerx.NamespaceClient;
import com.twosigma.beakerx.autocomplete.AutocompleteResult;
import com.twosigma.beakerx.evaluator.BaseEvaluator;
import com.twosigma.beakerx.NamespaceClient;
import com.twosigma.beakerx.evaluator.JobDescriptor;
import com.twosigma.beakerx.evaluator.TempFolderFactory;
import com.twosigma.beakerx.evaluator.TempFolderFactoryImpl;
Expand All @@ -40,12 +40,11 @@
import com.twosigma.beakerx.scala.serializers.ScalaPrimitiveTypeListOfListSerializer;
import com.twosigma.beakerx.scala.serializers.ScalaPrimitiveTypeMapSerializer;
import com.twosigma.beakerx.scala.serializers.ScalaTableDeSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ScalaEvaluator extends BaseEvaluator {

Expand Down Expand Up @@ -187,14 +186,11 @@ private void newAutoCompleteEvaluator() throws MalformedURLException {
acloader_cp + File.pathSeparatorChar + System.getProperty("java.class.path"), outDir);

if (!imports.isEmpty()) {
for (int i = 0; i < imports.getImportPaths().size(); i++) {
String imp = imports.getImportPaths().get(i).asString().trim();
imp = adjustImport(imp);
if (!imp.isEmpty()) {
if (!acshell.addImport(imp))
logger.warn("ERROR: cannot add import '{}'", imp);
}
}
String[] strings = imports.getImportPaths().stream().map(importPath -> {
String trim = importPath.asString().trim();
return adjustImport(trim);
}).toArray(String[]::new);
acshell.addImports(strings);
}

// ensure object is created
Expand All @@ -214,9 +210,7 @@ void newEvaluator() {
loader_cp + File.pathSeparatorChar + System.getProperty("java.class.path"), getOutDir());

if (!getImports().isEmpty()) {
for (ImportPath importPath : getImports().getImportPaths()) {
addImportToShell(importPath);
}
addImportsToShell(getImports().getImportPaths());
}

logger.debug("creating beaker object");
Expand All @@ -230,6 +224,16 @@ void newEvaluator() {
}
}

private void addImportsToShell(List<ImportPath> importsPaths) {
if (!importsPaths.isEmpty()) {
String[] imp = importsPaths.stream().map(importPath -> adjustImport(importPath.asString())).toArray(String[]::new);
logger.debug("importing : {}", importsPaths);
if (!shell.addImports(imp)) {
logger.warn("ERROR: cannot add import '{}'", imp);
}
}
}

private void addImportToShell(ImportPath importPath) {
String imp = importPath.asString().trim();
imp = adjustImport(imp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class ScalaEvaluatorGlue(val cl: ClassLoader, var cp: String, val replClassdir:
}
}

def addImports(names: Array[String]) : Boolean = {
addImport(names.mkString(", "))
}

def evaluate2(code: String): String = {
baos.reset()
try {
Expand Down