Search in sources :

Example 16 with OAbstractPaginatedStorage

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));
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OWriteCache(com.orientechnologies.orient.core.storage.cache.OWriteCache) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OStorage(com.orientechnologies.orient.core.storage.OStorage) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) Test(org.testng.annotations.Test)

Example 17 with OAbstractPaginatedStorage

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());
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OWriteCache(com.orientechnologies.orient.core.storage.cache.OWriteCache) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OStorage(com.orientechnologies.orient.core.storage.OStorage) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) Test(org.testng.annotations.Test)

Example 18 with OAbstractPaginatedStorage

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);
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OWriteCache(com.orientechnologies.orient.core.storage.cache.OWriteCache) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OStorage(com.orientechnologies.orient.core.storage.OStorage) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 19 with OAbstractPaginatedStorage

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();
        }
    }
}
Also used : OStorage(com.orientechnologies.orient.core.storage.OStorage) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 20 with OAbstractPaginatedStorage

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);
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

OAbstractPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage)38 OStorage (com.orientechnologies.orient.core.storage.OStorage)12 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)9 OWriteCache (com.orientechnologies.orient.core.storage.cache.OWriteCache)7 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)5 Test (org.testng.annotations.Test)5 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)4 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)4 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)4 OLocalPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage)4 File (java.io.File)4 BeforeClass (org.testng.annotations.BeforeClass)4 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)3 ORecordId (com.orientechnologies.orient.core.id.ORecordId)3 IOException (java.io.IOException)3 OLockException (com.orientechnologies.common.concur.lock.OLockException)2 OException (com.orientechnologies.common.exception.OException)2 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)2 ORID (com.orientechnologies.orient.core.id.ORID)2 ORemoteIndexEngine (com.orientechnologies.orient.core.index.engine.ORemoteIndexEngine)2