use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class ORidBagTest method testFromEmbeddedToSBTreeAndBackTx.
public void testFromEmbeddedToSBTreeAndBackTx() throws IOException {
OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(7);
OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.setValue(-1);
if (database.getStorage() instanceof OStorageProxy) {
OServerAdmin server = new OServerAdmin(database.getURL()).connect("root", ODatabaseHelper.getServerRootPassword());
server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD, 7);
server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD, -1);
server.close();
}
ORidBag ridBag = new ORidBag();
ODocument document = new ODocument();
document.field("ridBag", ridBag);
Assert.assertTrue(ridBag.isEmbedded());
database.begin();
document.save();
database.commit();
document.reload();
ridBag = document.field("ridBag");
Assert.assertTrue(ridBag.isEmbedded());
List<OIdentifiable> addedItems = new ArrayList<OIdentifiable>();
database.begin();
for (int i = 0; i < 6; i++) {
ODocument docToAdd = new ODocument();
docToAdd.save();
ridBag.add(docToAdd);
addedItems.add(docToAdd);
}
document.save();
database.commit();
document.reload();
ridBag = document.field("ridBag");
Assert.assertTrue(ridBag.isEmbedded());
ODocument docToAdd = new ODocument();
ridBag.add(docToAdd);
addedItems.add(docToAdd);
database.begin();
document.save();
database.commit();
Assert.assertTrue(!ridBag.isEmbedded());
List<OIdentifiable> addedItemsCopy = new ArrayList<OIdentifiable>(addedItems);
for (OIdentifiable id : ridBag) Assert.assertTrue(addedItems.remove(id));
Assert.assertTrue(addedItems.isEmpty());
document.reload();
ridBag = document.field("ridBag");
Assert.assertTrue(!ridBag.isEmbedded());
addedItems.addAll(addedItemsCopy);
for (OIdentifiable id : ridBag) Assert.assertTrue(addedItems.remove(id));
Assert.assertTrue(addedItems.isEmpty());
addedItems.addAll(addedItemsCopy);
for (int i = 0; i < 3; i++) ridBag.remove(addedItems.remove(i));
addedItemsCopy.clear();
addedItemsCopy.addAll(addedItems);
database.begin();
document.save();
database.commit();
Assert.assertTrue(!ridBag.isEmbedded());
for (OIdentifiable id : ridBag) Assert.assertTrue(addedItems.remove(id));
Assert.assertTrue(addedItems.isEmpty());
document.reload();
ridBag = document.field("ridBag");
Assert.assertTrue(!ridBag.isEmbedded());
addedItems.addAll(addedItemsCopy);
for (OIdentifiable id : ridBag) Assert.assertTrue(addedItems.remove(id));
Assert.assertTrue(addedItems.isEmpty());
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OSBTreeRidBagTest method beforeMethod.
@BeforeMethod
public void beforeMethod() throws IOException {
topThreshold = OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.getValueAsInteger();
bottomThreshold = OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.getValueAsInteger();
if (database.getStorage() instanceof OStorageProxy) {
OServerAdmin server = new OServerAdmin(database.getURL()).connect("root", ODatabaseHelper.getServerRootPassword());
server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD, -1);
server.setGlobalConfiguration(OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD, -1);
server.close();
}
OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1);
OGlobalConfiguration.RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD.setValue(-1);
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class RecordReloadTest method documentReloadLatestVersionLinkedValueTwo.
public void documentReloadLatestVersionLinkedValueTwo() throws Exception {
if (!(database.getStorage() instanceof OStorageProxy))
return;
ExecutorService executor = Executors.newSingleThreadExecutor();
final ODocument document = new ODocument();
document.field("value", "value one");
ODocument linkedValue = new ODocument();
linkedValue.field("val", "value 1");
document.field("link", linkedValue);
document.save();
final ORID rid = document.getIdentity();
final Future<?> future = executor.submit(new Runnable() {
@Override
public void run() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx(url);
db.open("admin", "admin");
ODocument doc = db.load(rid);
ODocument linkedValue = doc.field("link");
linkedValue.field("val", "value 2");
linkedValue.save();
db.close();
}
});
future.get();
document.reload("*:1", true, false);
linkedValue = document.field("link");
Assert.assertEquals(linkedValue.field("val"), "value 1");
}
Aggregations