Issue #1343: Fix Derived Parameter clean up of global map performance

Change-Id: Id5a37b16ffe311891a39acd21dab792d6c62fb29

Former-commit-id: 3fb4137264 [formerly a4ca44195e] [formerly 94ff0868d8 [formerly eeed667765a9da192ba4d28923fa447d8ea81437]]
Former-commit-id: 94ff0868d8
Former-commit-id: 57b23523dc
This commit is contained in:
Richard Peter 2012-11-20 16:40:01 -06:00
parent 78cad6b0e1
commit 1ee2e40970

View file

@ -61,7 +61,7 @@ public class MasterDerivScript extends PythonInterpreter {
private static final String DATA_NAME = "Data"; private static final String DATA_NAME = "Data";
private Map<Object, String> prevArgs = new HashMap<Object, String>(); private final Map<Object, List<String>> prevArgs = new HashMap<Object, List<String>>();
/** /**
* Constructor * Constructor
@ -86,7 +86,14 @@ public class MasterDerivScript extends PythonInterpreter {
throws JepException { throws JepException {
this.prevArgs.clear(); this.prevArgs.clear();
executeFunctionInternal(name, args); executeFunctionInternal(name, args);
cleanupGlobals(); jep.eval("globalsRef=globals()");
for (List<String> pArgs : prevArgs.values()) {
for (String arg : pArgs) {
jep.eval(arg + " = None");
jep.eval("del globalsRef['" + arg + "']");
}
}
this.prevArgs.clear(); this.prevArgs.clear();
return getExecutionResult(); return getExecutionResult();
} }
@ -122,7 +129,7 @@ public class MasterDerivScript extends PythonInterpreter {
protected void evaluateArgument(String argName, Object argValue) protected void evaluateArgument(String argName, Object argValue)
throws JepException { throws JepException {
if (prevArgs.containsKey(argValue)) { if (prevArgs.containsKey(argValue)) {
jep.eval(argName + " = " + prevArgs.get(argValue)); jep.eval(argName + " = " + prevArgs.get(argValue).get(0));
} else if (argValue instanceof List) { } else if (argValue instanceof List) {
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
List valList = (List) argValue; List valList = (List) argValue;
@ -222,7 +229,7 @@ public class MasterDerivScript extends PythonInterpreter {
// create a list of arrays // create a list of arrays
jep.eval(argName + " = []"); jep.eval(argName + " = []");
for (int argIdx = 0; argIdx < valList.length; argIdx++) { for (int argIdx = 0; argIdx < valList.length; argIdx++) {
IDataRecord val = (IDataRecord) valList[argIdx]; IDataRecord val = valList[argIdx];
jep.eval(argName + ".append(None)"); jep.eval(argName + ".append(None)");
// setNumeric won't work with indexed objects // setNumeric won't work with indexed objects
evaluateArgument("__tmp", val); evaluateArgument("__tmp", val);
@ -248,7 +255,12 @@ public class MasterDerivScript extends PythonInterpreter {
} else { } else {
super.evaluateArgument(argName, argValue); super.evaluateArgument(argName, argValue);
} }
prevArgs.put(argValue, argName); List<String> pArgs = prevArgs.get(argValue);
if (pArgs == null) {
pArgs = new ArrayList<String>();
prevArgs.put(argValue, pArgs);
}
pArgs.add(argName);
} }
/** /**