use of com.orientechnologies.orient.core.command.script.OCommandScript in project orientdb by orientechnologies.
the class LuceneSingleFieldEmbeddedTest method init.
@Before
public void init() {
InputStream stream = ClassLoader.getSystemResourceAsStream("testLuceneIndex.sql");
db.command(new OCommandScript("sql", getScriptFromStream(stream))).execute();
db.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE")).execute();
db.command(new OCommandSQL("create index Song.author on Song (author) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.orientechnologies.orient.core.command.script.OCommandScript in project orientdb by orientechnologies.
the class LuceneSkipLimitTest method init.
@Before
public void init() {
InputStream stream = ClassLoader.getSystemResourceAsStream("testLuceneIndex.sql");
db.command(new OCommandScript("sql", getScriptFromStream(stream))).execute();
db.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE")).execute();
db.command(new OCommandSQL("create index Song.author on Song (author) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.orientechnologies.orient.core.command.script.OCommandScript in project orientdb by orientechnologies.
the class TransactionIsolationTest method testIsolationRepeatableReadScript.
@Test
public void testIsolationRepeatableReadScript() throws ExecutionException, InterruptedException {
final ODatabaseDocumentTx db1 = new ODatabaseDocumentTx(url);
db1.open("admin", "admin");
final ODocument record1 = new ODocument();
record1.field("name", "This is the first version").save();
Future<List<OIdentifiable>> txFuture = Orient.instance().submit(new Callable<List<OIdentifiable>>() {
@Override
public List<OIdentifiable> call() throws Exception {
String cmd = "";
cmd += "begin isolation REPEATABLE_READ;";
cmd += "let r1 = select from " + record1.getIdentity() + ";";
cmd += "sleep 2000;";
cmd += "let r2 = select from " + record1.getIdentity() + ";";
cmd += "commit;";
cmd += "return $r2;";
db1.activateOnCurrentThread();
return db1.command(new OCommandScript("sql", cmd)).execute();
}
});
Thread.sleep(500);
// CHANGE THE RECORD FROM DB2
ODatabaseDocumentTx db2 = new ODatabaseDocumentTx(url);
db2.open("admin", "admin");
ODocument record2 = db2.load(record1.getIdentity());
record2.field("name", "This is the second version").save();
List<OIdentifiable> txRecord = txFuture.get();
Assert.assertNotNull(txRecord);
Assert.assertEquals(txRecord.size(), 1);
Assert.assertEquals(((ODocument) txRecord.get(0).getRecord()).field("name"), "This is the first version");
db1.activateOnCurrentThread();
db1.close();
db2.activateOnCurrentThread();
db2.close();
}
use of com.orientechnologies.orient.core.command.script.OCommandScript 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;
}
use of com.orientechnologies.orient.core.command.script.OCommandScript in project orientdb by orientechnologies.
the class OCommandExecutorSQLScriptTest method testScriptSubContext.
@Test
public void testScriptSubContext() throws Exception {
StringBuilder script = new StringBuilder();
script.append("let $a = select from foo limit 1\n");
script.append("select from (traverse doesnotexist from $a)\n");
Iterable qResult = db.command(new OCommandScript("sql", script.toString())).execute();
Assert.assertNotNull(qResult);
Iterator iterator = qResult.iterator();
Assert.assertTrue(iterator.hasNext());
iterator.next();
Assert.assertFalse(iterator.hasNext());
}
Aggregations