Search in sources :

Example 86 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class ORidBagTest method testAddRemoveSBTreeContainsValues.

public void testAddRemoveSBTreeContainsValues() {
    ORidBag bag = new ORidBag();
    bag.setAutoConvertToRecord(false);
    bag.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:2"));
    bag.add(new ORecordId("#77:3"));
    bag.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:4"));
    bag.add(new ORecordId("#77:5"));
    bag.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.remove(new ORecordId("#77:1"));
    bag.remove(new ORecordId("#77:2"));
    bag.remove(new ORecordId("#77:2"));
    bag.remove(new ORecordId("#77:4"));
    bag.remove(new ORecordId("#77:6"));
    final List<OIdentifiable> rids = new ArrayList<OIdentifiable>();
    rids.add(new ORecordId("#77:3"));
    rids.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:4"));
    rids.add(new ORecordId("#77:5"));
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
    for (OIdentifiable identifiable : bag) rids.add(identifiable);
    doc = new ODocument();
    ORidBag otherBag = new ORidBag();
    for (OIdentifiable id : bag) otherBag.add(id);
    assertEmbedded(otherBag.isEmbedded());
    doc.field("ridbag", otherBag);
    doc.save();
    rid = doc.getIdentity();
    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 87 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class ORidBagTest method testAddSBTreeAddInMemoryIterate.

public void testAddSBTreeAddInMemoryIterate() {
    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"));
    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:0"));
    rids.add(new ORecordId("#77:0"));
    bag.add(new ORecordId("#77:1"));
    rids.add(new ORecordId("#77:1"));
    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:5"));
    rids.add(new ORecordId("#77:5"));
    bag.add(new ORecordId("#77:6"));
    rids.add(new ORecordId("#77:6"));
    assertEmbedded(bag.isEmbedded());
    for (OIdentifiable identifiable : bag) assertTrue(rids.remove(identifiable));
    assertTrue(rids.isEmpty());
    for (OIdentifiable identifiable : bag) rids.add(identifiable);
    doc = new ODocument();
    final ORidBag otherBag = new ORidBag();
    for (OIdentifiable id : bag) otherBag.add(id);
    doc.field("ridbag", otherBag);
    doc.save();
    rid = doc.getIdentity();
    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 88 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method listProperties.

@ConsoleCommand(description = "Display the database properties")
public void listProperties() {
    if (currentDatabase == null)
        return;
    final OStorage stg = currentDatabase.getStorage();
    final OStorageConfiguration dbCfg = stg.getConfiguration();
    message("\n\nDATABASE PROPERTIES");
    if (dbCfg.getProperties() != null) {
        final List<ODocument> resultSet = new ArrayList<ODocument>();
        if (dbCfg.name != null)
            resultSet.add(new ODocument().field("NAME", "Name").field("VALUE", dbCfg.name));
        resultSet.add(new ODocument().field("NAME", "Version").field("VALUE", dbCfg.version));
        resultSet.add(new ODocument().field("NAME", "Conflict-Strategy").field("VALUE", dbCfg.getConflictStrategy()));
        resultSet.add(new ODocument().field("NAME", "Date-Format").field("VALUE", dbCfg.dateFormat));
        resultSet.add(new ODocument().field("NAME", "Datetime-Format").field("VALUE", dbCfg.dateTimeFormat));
        resultSet.add(new ODocument().field("NAME", "Timezone").field("VALUE", dbCfg.getTimeZone().getID()));
        resultSet.add(new ODocument().field("NAME", "Locale-Country").field("VALUE", dbCfg.getLocaleCountry()));
        resultSet.add(new ODocument().field("NAME", "Locale-Language").field("VALUE", dbCfg.getLocaleLanguage()));
        resultSet.add(new ODocument().field("NAME", "Charset").field("VALUE", dbCfg.getCharset()));
        resultSet.add(new ODocument().field("NAME", "Schema-RID").field("VALUE", dbCfg.schemaRecordId, OType.LINK));
        resultSet.add(new ODocument().field("NAME", "Index-Manager-RID").field("VALUE", dbCfg.indexMgrRecordId, OType.LINK));
        resultSet.add(new ODocument().field("NAME", "Dictionary-RID").field("VALUE", dbCfg.dictionaryRecordId, OType.LINK));
        final OTableFormatter formatter = new OTableFormatter(this);
        formatter.writeRecords(resultSet, -1);
        message("\n");
        if (!dbCfg.getProperties().isEmpty()) {
            message("\n\nDATABASE CUSTOM PROPERTIES:");
            final List<ODocument> dbResultSet = new ArrayList<ODocument>();
            for (OStorageEntryConfiguration cfg : dbCfg.getProperties()) dbResultSet.add(new ODocument().field("NAME", cfg.name).field("VALUE", cfg.value));
            final OTableFormatter dbFormatter = new OTableFormatter(this);
            dbFormatter.writeRecords(dbResultSet, -1);
        }
    }
}
Also used : OStorage(com.orientechnologies.orient.core.storage.OStorage) OStorageEntryConfiguration(com.orientechnologies.orient.core.config.OStorageEntryConfiguration) OStorageConfiguration(com.orientechnologies.orient.core.config.OStorageConfiguration) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Example 89 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class LocalCreateBinaryDocumentSpeedTest method cycle.

@Override
@Test(enabled = false)
public void cycle() {
    final OStorage storage = database.getStorage();
    ((OAbstractPaginatedStorage) storage).startGatheringPerformanceStatisticForCurrentThread();
    record = new ORecordBytes(database, payload);
    record.save();
    if (data.getCyclesDone() == data.getCycles() - 1)
        database.commit();
    OSessionStoragePerformanceStatistic sessionStoragePerformanceStatistic = ((OAbstractPaginatedStorage) storage).completeGatheringPerformanceStatisticForCurrentThread();
    System.out.println(sessionStoragePerformanceStatistic.toDocument().toJSON("prettyPrint"));
}
Also used : ORecordBytes(com.orientechnologies.orient.core.record.impl.ORecordBytes) 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) OrientMonoThreadTest(com.orientechnologies.orient.test.database.base.OrientMonoThreadTest) Test(org.testng.annotations.Test)

Example 90 with OStorage

use of com.orientechnologies.orient.core.storage.OStorage in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method info.

@ConsoleCommand(aliases = { "status" }, description = "Display information about the database", onlineHelp = "Console-Command-Info")
public void info() {
    if (currentDatabaseName != null) {
        message("\nCurrent database: " + currentDatabaseName + " (url=" + currentDatabase.getURL() + ")");
        final OStorage stg = currentDatabase.getStorage();
        if (stg instanceof OStorageRemote) {
            listServers();
        }
        listProperties();
        listClusters(null);
        listClasses();
        listIndexes();
    }
}
Also used : OStorageRemote(com.orientechnologies.orient.client.remote.OStorageRemote) OStorage(com.orientechnologies.orient.core.storage.OStorage) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Aggregations

OStorage (com.orientechnologies.orient.core.storage.OStorage)90 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)31 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)23 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)22 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)21 ORecordId (com.orientechnologies.orient.core.id.ORecordId)20 OAutoshardedStorage (com.orientechnologies.orient.core.storage.OAutoshardedStorage)18 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)18 OPhysicalPosition (com.orientechnologies.orient.core.storage.OPhysicalPosition)12 OAbstractPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage)11 File (java.io.File)11 ORID (com.orientechnologies.orient.core.id.ORID)10 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)7 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)7 Test (org.testng.annotations.Test)7 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)6 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)6 OCommandOutputListener (com.orientechnologies.orient.core.command.OCommandOutputListener)5 OSchemaException (com.orientechnologies.orient.core.exception.OSchemaException)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)5