Search in sources :

Example 56 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class ORidBagTest method testAddRemoveNotExisting.

public void testAddRemoveNotExisting() {
    List<OIdentifiable> rids = new ArrayList<OIdentifiable>();
    ORidBag bag = new ORidBag();
    assertEmbedded(bag.isEmbedded());
    bag.setAutoConvertToRecord(false);
    bag.add(new ORecordId("#77:2"));
    rids.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:2"));
    rids.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:3"));
    rids.add(new ORecordId("#77:3"));
    bag.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:5"));
    rids.add(new ORecordId("#77:5"));
    bag.add(new ORecordId("#77:6"));
    rids.add(new ORecordId("#77:6"));
    assertEmbedded(bag.isEmbedded());
    ODocument doc = new ODocument();
    doc.field("ridbag", bag);
    doc.save();
    ORID rid = doc.getIdentity();
    OStorage storage = database.getStorage();
    database.close();
    storage.close(true, false);
    database = new ODatabaseDocumentTx(database.getURL());
    database.open("admin", "admin");
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    bag.add(new ORecordId("#77:2"));
    rids.add(new ORecordId("#77:2"));
    bag.remove(new ORecordId("#77:4"));
    rids.remove(new ORecordId("#77:4"));
    bag.remove(new ORecordId("#77:4"));
    rids.remove(new ORecordId("#77:4"));
    bag.remove(new ORecordId("#77:2"));
    rids.remove(new ORecordId("#77:2"));
    bag.remove(new ORecordId("#77:2"));
    rids.remove(new ORecordId("#77:2"));
    bag.remove(new ORecordId("#77:7"));
    rids.remove(new ORecordId("#77:7"));
    bag.remove(new ORecordId("#77:8"));
    rids.remove(new ORecordId("#77:8"));
    bag.remove(new ORecordId("#77:8"));
    rids.remove(new ORecordId("#77:8"));
    bag.remove(new ORecordId("#77:8"));
    rids.remove(new ORecordId("#77:8"));
    assertEmbedded(bag.isEmbedded());
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
    for (OIdentifiable identifiable : bag) rids.add(identifiable);
    doc.save();
    doc = database.load(rid);
    doc.setLazyLoad(false);
    bag = doc.field("ridbag");
    assertEmbedded(bag.isEmbedded());
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ORID(com.orientechnologies.orient.core.id.ORID) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 57 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class ORidBagTest method testSaveLoad.

public void testSaveLoad() throws Exception {
    Set<OIdentifiable> expected = new HashSet<OIdentifiable>(8);
    expected.add(new ORecordId("#77:12"));
    expected.add(new ORecordId("#77:13"));
    expected.add(new ORecordId("#77:14"));
    expected.add(new ORecordId("#77:15"));
    expected.add(new ORecordId("#77:16"));
    expected.add(new ORecordId("#77:17"));
    expected.add(new ORecordId("#77:18"));
    expected.add(new ORecordId("#77:19"));
    expected.add(new ORecordId("#77:20"));
    expected.add(new ORecordId("#77:21"));
    expected.add(new ORecordId("#77:22"));
    ODocument doc = new ODocument();
    final ORidBag bag = new ORidBag();
    bag.addAll(expected);
    doc.field("ridbag", bag);
    assertEmbedded(bag.isEmbedded());
    doc.save();
    final ORID id = doc.getIdentity();
    OStorage storage = database.getStorage();
    database.close();
    storage.close(true, false);
    database = new ODatabaseDocumentTx(database.getURL());
    database.open("admin", "admin");
    doc = database.load(id);
    doc.setLazyLoad(false);
    final ORidBag loaded = doc.field("ridbag");
    assertEmbedded(loaded.isEmbedded());
    Assert.assertEquals(loaded.size(), expected.size());
    for (OIdentifiable identifiable : loaded) Assert.assertTrue(expected.remove(identifiable));
    Assert.assertTrue(expected.isEmpty());
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ORID(com.orientechnologies.orient.core.id.ORID) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 58 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class LocalCreateIndexedDocumentSpeedTest method init.

@Override
public void init() {
    Orient.instance().getProfiler().startRecording();
    database = new ODatabaseDocumentTx(System.getProperty("url")).open("admin", "admin");
    record = database.newInstance();
    // REMOVE THE INDEX
    System.out.println("Remove index...");
    database.getMetadata().getSchema().getClass("Profile").getProperty("nick").dropIndexes();
    System.out.println("Ok");
    database.declareIntent(new OIntentMassiveInsert());
    database.begin(TXTYPE.NOTX);
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OIntentMassiveInsert(com.orientechnologies.orient.core.intent.OIntentMassiveInsert)

Example 59 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class LocalMTCreateDocumentSpeedTest method init.

@BeforeClass
public void init() {
    OGlobalConfiguration.USE_WAL.setValue(false);
    database = new ODatabaseDocumentTx(System.getProperty("url"));
    database.setSerializer(new ORecordSerializerBinary());
    if (database.exists()) {
        database.open("admin", "admin");
        database.drop();
    }
    database.create();
    database.getMetadata().getSchema().createClass("Account");
    final OSecurity security = database.getMetadata().getSecurity();
    for (int i = 0; i < 100; i++) {
        users.add("user" + i);
        security.createUser("user" + i, "user" + i, "admin");
    }
    futures = new ArrayList<Future>();
    for (int i = 0; i < 1; i++) futures.add(executorService.submit(new Saver()));
}
Also used : ORecordSerializerBinary(com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary) OSecurity(com.orientechnologies.orient.core.metadata.security.OSecurity) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) BeforeClass(org.testng.annotations.BeforeClass)

Example 60 with ODatabaseDocumentTx

use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.

the class MemoryLeaksTest method createLotsOfRecordsWithBigContent.

@Test
public void createLotsOfRecordsWithBigContent() {
    ODatabaseDocumentTx vDb = new ODatabaseDocumentTx("plocal:target/MemoryLeaksTest");
    vDb.create();
    for (int i = 0; i < 10000000; i++) {
        ODocument vDoc = new ODocument();
        vDoc.field("test", new byte[100000]);
        vDoc.save();
        if (i % 10 == 0)
            System.out.println("Records created:" + i + " cacheSize: " + vDb.getLocalCache().getSize());
    }
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Aggregations

ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)590 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)257 Test (org.testng.annotations.Test)182 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)120 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)81 Test (org.junit.Test)79 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)61 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)47 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)46 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)41 ORID (com.orientechnologies.orient.core.id.ORID)39 ORecordId (com.orientechnologies.orient.core.id.ORecordId)34 Before (org.junit.Before)34 File (java.io.File)33 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)25 ArrayList (java.util.ArrayList)25 BeforeClass (org.testng.annotations.BeforeClass)23 BeforeMethod (org.testng.annotations.BeforeMethod)23 OStorage (com.orientechnologies.orient.core.storage.OStorage)21 List (java.util.List)20