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());
}
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());
}
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);
}
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()));
}
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());
}
}
Aggregations