Search in sources :

Example 1 with ORecordIteratorClass

use of com.orientechnologies.orient.core.iterator.ORecordIteratorClass in project orientdb by orientechnologies.

the class BrowseSpeedTest method browseClusters.

protected void browseClusters() {
    ODatabaseDocumentTx db = openDatabase();
    final long total = db.countClass(className);
    ORecordIteratorClass iterator = new ORecordIteratorClass(db, db, className, true);
    long start = System.currentTimeMillis();
    int loaded = 0;
    ORecord rec;
    while (iterator.hasNext()) {
        rec = iterator.next();
        if (rec != null)
            loaded++;
    }
    long end = System.currentTimeMillis();
    System.out.println("Iterator " + total + " and loaded " + loaded + " took " + (end - start));
    db.close();
}
Also used : ORecordIteratorClass(com.orientechnologies.orient.core.iterator.ORecordIteratorClass) ORecord(com.orientechnologies.orient.core.record.ORecord) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Example 2 with ORecordIteratorClass

use of com.orientechnologies.orient.core.iterator.ORecordIteratorClass in project orientdb by orientechnologies.

the class OCommandExecutorSQLResultsetAbstract method searchInClasses.

protected Iterator<? extends OIdentifiable> searchInClasses(final OClass iCls, final boolean iPolymorphic, final boolean iAscendentOrder) {
    final ODatabaseDocumentInternal database = getDatabase();
    database.checkSecurity(ORule.ResourceGeneric.CLASS, ORole.PERMISSION_READ, iCls.getName().toLowerCase());
    final ORID[] range = getRange();
    if (iAscendentOrder)
        return new ORecordIteratorClass<ORecord>(database, database, iCls.getName(), iPolymorphic, isUseCache(), false).setRange(range[0], range[1]);
    else
        return new ORecordIteratorClassDescendentOrder<ORecord>(database, database, iCls.getName(), iPolymorphic).setRange(range[0], range[1]);
}
Also used : ORecordIteratorClass(com.orientechnologies.orient.core.iterator.ORecordIteratorClass) ORID(com.orientechnologies.orient.core.id.ORID) ORecordIteratorClassDescendentOrder(com.orientechnologies.orient.core.iterator.ORecordIteratorClassDescendentOrder) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 3 with ORecordIteratorClass

use of com.orientechnologies.orient.core.iterator.ORecordIteratorClass in project orientdb by orientechnologies.

the class OSelectStatement method searchInClasses.

protected Iterator<? extends OIdentifiable> searchInClasses(final OClass iCls, final boolean iPolymorphic, final boolean iAscendentOrder) {
    final ODatabaseDocumentInternal database = getDatabase();
    database.checkSecurity(ORule.ResourceGeneric.CLASS, ORole.PERMISSION_READ, iCls.getName().toLowerCase());
    // TODO
    final ORID[] range = new ORID[2];
    // TODO
    boolean useCache = false;
    if (iAscendentOrder)
        return new ORecordIteratorClass<ORecord>(database, database, iCls.getName(), iPolymorphic, useCache, false).setRange(range[0], range[1]);
    else
        return new ORecordIteratorClassDescendentOrder<ORecord>(database, database, iCls.getName(), iPolymorphic).setRange(range[0], range[1]);
}
Also used : ORecordIteratorClass(com.orientechnologies.orient.core.iterator.ORecordIteratorClass) ORID(com.orientechnologies.orient.core.id.ORID) ORecordIteratorClassDescendentOrder(com.orientechnologies.orient.core.iterator.ORecordIteratorClassDescendentOrder) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)

Example 4 with ORecordIteratorClass

use of com.orientechnologies.orient.core.iterator.ORecordIteratorClass in project orientdb by orientechnologies.

the class IteratorSpeedTest method testIterationSpeed.

public void testIterationSpeed() {
    ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:speedTest");
    db.create();
    OClass oClass = db.getMetadata().getSchema().createClass("SpeedTest");
    for (int i = 0; i < 1000000; i++) {
        ODocument document = new ODocument("SpeedTest");
        document.save();
    }
    ORecordIteratorClass iterator = new ORecordIteratorClass(db, db, "SpeedTest", true);
    iterator.setRange(new ORecordId(oClass.getDefaultClusterId(), 999998), new ORecordId(oClass.getDefaultClusterId(), 999999));
    long start = System.nanoTime();
    while (iterator.hasNext()) iterator.next();
    long end = System.nanoTime();
    System.out.println(end - start);
    db.drop();
}
Also used : ORecordIteratorClass(com.orientechnologies.orient.core.iterator.ORecordIteratorClass) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 5 with ORecordIteratorClass

use of com.orientechnologies.orient.core.iterator.ORecordIteratorClass in project orientdb by orientechnologies.

the class BrowseSpeedTest method browseClusters.

protected void browseClusters() {
    ODatabaseDocumentTx db = openDatabase();
    final long total = db.countClass(CLASS);
    ORecordIteratorClass iterator = new ORecordIteratorClass(db, db, CLASS, true);
    long start = System.currentTimeMillis();
    int loaded = 0;
    ORecord rec;
    while (iterator.hasNext()) {
        rec = iterator.next();
        if (rec != null)
            loaded++;
    }
    long end = System.currentTimeMillis();
    System.out.println("Iterator " + total + " and loaded " + loaded + " took " + (end - start));
    db.close();
}
Also used : ORecordIteratorClass(com.orientechnologies.orient.core.iterator.ORecordIteratorClass) ORecord(com.orientechnologies.orient.core.record.ORecord) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Aggregations

ORecordIteratorClass (com.orientechnologies.orient.core.iterator.ORecordIteratorClass)5 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)3 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)2 ORID (com.orientechnologies.orient.core.id.ORID)2 ORecordIteratorClassDescendentOrder (com.orientechnologies.orient.core.iterator.ORecordIteratorClassDescendentOrder)2 ORecord (com.orientechnologies.orient.core.record.ORecord)2 ORecordId (com.orientechnologies.orient.core.id.ORecordId)1 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1