use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class LuceneInsertMultithreadTest method testConcurrentInsertWithIndex.
@Test
public void testConcurrentInsertWithIndex() throws Exception {
databaseDocumentTx = new ODatabaseDocumentTx(url);
if (!url.contains("remote:") && databaseDocumentTx.exists()) {
databaseDocumentTx.open("admin", "admin");
databaseDocumentTx.drop();
databaseDocumentTx.create();
} else {
databaseDocumentTx.create();
}
OSchema schema = databaseDocumentTx.getMetadata().getSchema();
if (schema.getClass("City") == null) {
OClass oClass = schema.createClass("City");
oClass.createProperty("name", OType.STRING);
oClass.createIndex("City.name", "FULLTEXT", null, null, "LUCENE", new String[] { "name" });
}
Thread[] threads = new Thread[THREADS + RTHREADS];
for (int i = 0; i < THREADS; ++i) threads[i] = new Thread(new LuceneInsertThread(CYCLE), "ConcurrentWriteTest" + i);
for (int i = THREADS; i < THREADS + RTHREADS; ++i) threads[i] = new Thread(new LuceneReadThread(CYCLE), "ConcurrentReadTest" + i);
for (int i = 0; i < THREADS + RTHREADS; ++i) threads[i].start();
for (int i = 0; i < THREADS + RTHREADS; ++i) threads[i].join();
OIndex idx = schema.getClass("City").getClassIndex("City.name");
Assert.assertEquals(idx.getSize(), THREADS * CYCLE);
databaseDocumentTx.drop();
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class LuceneInsertUpdateSingleDocumentNoTxTest method init.
@Before
public void init() {
OSchema schema = db.getMetadata().getSchema();
OClass oClass = schema.createClass("City");
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class LuceneInsertUpdateSingleDocumentTransactionTest method testInsertUpdateTransactionWithIndex.
@Test
public void testInsertUpdateTransactionWithIndex() throws Exception {
db.close();
db.open("admin", "admin");
OSchema schema = db.getMetadata().getSchema();
schema.reload();
db.begin();
ODocument doc = new ODocument("City");
doc.field("name", "");
ODocument doc1 = new ODocument("City");
doc1.field("name", "");
doc = db.save(doc);
doc1 = db.save(doc1);
db.commit();
db.begin();
doc = db.load(doc);
doc1 = db.load(doc1);
doc.field("name", "Rome");
doc1.field("name", "Rome");
db.save(doc);
db.save(doc1);
db.commit();
OIndex idx = schema.getClass("City").getClassIndex("City.name");
Collection<?> coll = (Collection<?>) idx.get("Rome");
Assert.assertEquals(coll.size(), 2);
Assert.assertEquals(idx.getSize(), 2);
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class LuceneInsertUpdateTest method init.
@Before
public void init() {
OSchema schema = db.getMetadata().getSchema();
OClass oClass = schema.createClass("City");
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class LuceneInsertUpdateTransactionTest method init.
@Before
public void init() {
OSchema schema = db.getMetadata().getSchema();
OClass oClass = schema.createClass("City");
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
Aggregations