use of com.orientechnologies.orient.core.command.script.OCommandExecutorScript in project orientdb by orientechnologies.
the class OConsoleDatabaseApp method js.
@SuppressWarnings("unchecked")
@ConsoleCommand(splitInWords = false, description = "Execute javascript commands in the console")
public void js(@ConsoleParameter(name = "text", description = "The javascript to execute. Use 'db' to reference to a document database, 'gdb' for a graph database") final String iText) {
if (iText == null)
return;
resetResultSet();
long start = System.currentTimeMillis();
while (true) {
try {
final OCommandExecutorScript cmd = new OCommandExecutorScript();
cmd.parse(new OCommandScript("Javascript", iText));
currentResult = cmd.execute(null);
break;
} catch (ORetryQueryException e) {
continue;
}
}
float elapsedSeconds = getElapsedSecs(start);
parseResult();
if (currentResultSet != null) {
dumpResultSet(-1);
message("\nClient side script executed in %f sec(s). Returned %d records", elapsedSeconds, currentResultSet.size());
} else
message("\nClient side script executed in %f sec(s). Value returned is: %s", elapsedSeconds, currentResult);
}
use of com.orientechnologies.orient.core.command.script.OCommandExecutorScript in project orientdb by orientechnologies.
the class OFunction method execute.
public Object execute(final Map<Object, Object> iArgs) {
final long start = Orient.instance().getProfiler().startChrono();
Object result;
while (true) {
try {
if (callback != null)
return callback.call(iArgs);
final OCommandExecutorScript command = new OCommandExecutorScript();
command.parse(new OCommandScript(getLanguage(), getCode()));
result = command.execute(iArgs);
break;
} catch (ONeedRetryException e) {
continue;
} catch (ORetryQueryException e) {
continue;
}
}
if (Orient.instance().getProfiler().isRecording())
Orient.instance().getProfiler().stopChrono("db." + ODatabaseRecordThreadLocal.INSTANCE.get().getName() + ".function.execute", "Time to execute a function", start, "db.*.function.execute");
return result;
}
Aggregations