use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class ClassTest method testRename.
@Test
public void testRename() {
OSchema schema = db.getMetadata().getSchema();
OClass oClass = schema.createClass("ClassName");
final OStorage storage = db.getStorage();
final OAbstractPaginatedStorage paginatedStorage = (OAbstractPaginatedStorage) storage;
final OWriteCache writeCache = paginatedStorage.getWriteCache();
Assert.assertTrue(writeCache.exists("classname" + OPaginatedCluster.DEF_EXTENSION));
oClass.setName("ClassNameNew");
Assert.assertTrue(!writeCache.exists("classname" + OPaginatedCluster.DEF_EXTENSION));
Assert.assertTrue(writeCache.exists("classnamenew" + OPaginatedCluster.DEF_EXTENSION));
oClass.setName("ClassName");
Assert.assertTrue(!writeCache.exists("classnamenew" + OPaginatedCluster.DEF_EXTENSION));
Assert.assertTrue(writeCache.exists("classname" + OPaginatedCluster.DEF_EXTENSION));
}
use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class ClassTest method testShortName.
@Test
public void testShortName() {
OSchema schema = db.getMetadata().getSchema();
OClass oClass = schema.createClass(SHORTNAME_CLASS_NAME);
Assert.assertNull(oClass.getShortName());
Assert.assertNull(queryShortName());
final OStorage storage = db.getStorage();
if (storage instanceof OAbstractPaginatedStorage) {
final OAbstractPaginatedStorage paginatedStorage = (OAbstractPaginatedStorage) storage;
final OWriteCache writeCache = paginatedStorage.getWriteCache();
Assert.assertTrue(writeCache.exists(SHORTNAME_CLASS_NAME.toLowerCase() + OPaginatedCluster.DEF_EXTENSION));
}
String shortName = "shortname";
oClass.setShortName(shortName);
Assert.assertEquals(shortName, oClass.getShortName());
Assert.assertEquals(shortName, queryShortName());
// FAILS, saves null value and stores "null" string (not null value) internally
shortName = "null";
oClass.setShortName(shortName);
Assert.assertEquals(shortName, oClass.getShortName());
Assert.assertEquals(shortName, queryShortName());
oClass.setShortName(null);
Assert.assertNull(oClass.getShortName());
Assert.assertNull(queryShortName());
oClass.setShortName("");
Assert.assertNull(oClass.getShortName());
Assert.assertNull(queryShortName());
}
use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class ClassTest method testRenameClusterAlreadyExists.
@Test
public void testRenameClusterAlreadyExists() {
OSchema schema = db.getMetadata().getSchema();
OClass classOne = schema.createClass("ClassOne");
OClass classTwo = schema.createClass("ClassTwo");
final int clusterId = db.addCluster("classthree");
classTwo.addClusterId(clusterId);
ODocument document = new ODocument("ClassTwo");
document.save("classthree");
document = new ODocument("ClassTwo");
document.save();
document = new ODocument("ClassOne");
document.save();
Assert.assertEquals(db.countClass("ClassTwo"), 2);
Assert.assertEquals(db.countClass("ClassOne"), 1);
classOne.setName("ClassThree");
final OStorage storage = db.getStorage();
final OAbstractPaginatedStorage paginatedStorage = (OAbstractPaginatedStorage) storage;
final OWriteCache writeCache = paginatedStorage.getWriteCache();
Assert.assertTrue(writeCache.exists("classone" + OPaginatedCluster.DEF_EXTENSION));
Assert.assertEquals(db.countClass("ClassTwo"), 2);
Assert.assertEquals(db.countClass("ClassThree"), 1);
classOne.setName("ClassOne");
Assert.assertTrue(writeCache.exists("classone" + OPaginatedCluster.DEF_EXTENSION));
Assert.assertEquals(db.countClass("ClassTwo"), 2);
Assert.assertEquals(db.countClass("ClassOne"), 1);
}
use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class OProfileStorageStatement method execute.
@Override
public Object execute(OSQLAsynchQuery<ODocument> request, OCommandContext context, OProgressListener progressListener) {
try {
ODatabaseDocumentInternal db = getDatabase();
final OStorage storage = db.getStorage();
if (on) {
// activate the profiler
((OAbstractPaginatedStorage) storage).startGatheringPerformanceStatisticForCurrentThread();
ODocument result = new ODocument();
result.field("result", "OK");
request.getResultListener().result(result);
} else {
// stop the profiler and return the stats
final OSessionStoragePerformanceStatistic performanceStatistic = ((OAbstractPaginatedStorage) storage).completeGatheringPerformanceStatisticForCurrentThread();
if (performanceStatistic != null)
request.getResultListener().result(performanceStatistic.toDocument());
else {
ODocument result = new ODocument();
result.field("result", "Error: profiling of storage was not started.");
request.getResultListener().result(result);
}
}
return getResult(request);
} finally {
if (request.getResultListener() != null) {
request.getResultListener().end();
}
}
}
use of com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage in project orientdb by orientechnologies.
the class SBTreeTest method beforeClass.
@BeforeClass
public void beforeClass() {
buildDirectory = System.getProperty("buildDirectory");
if (buildDirectory == null)
buildDirectory = ".";
databaseDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDirectory + "/localSBTreeTest");
if (databaseDocumentTx.exists()) {
databaseDocumentTx.open("admin", "admin");
databaseDocumentTx.drop();
}
databaseDocumentTx.create();
sbTree = new OSBTree<Integer, OIdentifiable>("sbTree", ".sbt", false, ".nbt", (OAbstractPaginatedStorage) databaseDocumentTx.getStorage());
sbTree.create(OIntegerSerializer.INSTANCE, OLinkSerializer.INSTANCE, null, 1, false);
}
Aggregations