Search in sources :

Example 6 with OIdentifiable

use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.

the class OEmbeddedRidBag method convertRecords2Links.

@Override
public boolean convertRecords2Links() {
    for (int i = 0; i < entriesLength; i++) {
        final Object entry = entries[i];
        if (entry instanceof OIdentifiable) {
            final OIdentifiable identifiable = (OIdentifiable) entry;
            if (identifiable instanceof ORecord) {
                final ORecord record = (ORecord) identifiable;
                entries[i] = record.getIdentity();
            }
        }
    }
    return true;
}
Also used : ORecord(com.orientechnologies.orient.core.record.ORecord) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Example 7 with OIdentifiable

use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.

the class OEmbeddedRidBag method toString.

@Override
public String toString() {
    if (size < 10) {
        final StringBuilder sb = new StringBuilder(256);
        sb.append('[');
        for (final Iterator<OIdentifiable> it = this.iterator(); it.hasNext(); ) {
            try {
                OIdentifiable e = it.next();
                if (e != null) {
                    if (sb.length() > 1)
                        sb.append(", ");
                    sb.append(e.getIdentity());
                }
            } catch (NoSuchElementException ex) {
            // IGNORE THIS
            }
        }
        return sb.append(']').toString();
    } else
        return "[size=" + size + "]";
}
Also used : OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Example 8 with OIdentifiable

use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.

the class OEmbeddedRidBag method returnOriginalState.

@Override
public Object returnOriginalState(List<OMultiValueChangeEvent<OIdentifiable, OIdentifiable>> multiValueChangeEvents) {
    final OEmbeddedRidBag reverted = new OEmbeddedRidBag();
    for (OIdentifiable identifiable : this) reverted.add(identifiable);
    final ListIterator<OMultiValueChangeEvent<OIdentifiable, OIdentifiable>> listIterator = multiValueChangeEvents.listIterator(multiValueChangeEvents.size());
    while (listIterator.hasPrevious()) {
        final OMultiValueChangeEvent<OIdentifiable, OIdentifiable> event = listIterator.previous();
        switch(event.getChangeType()) {
            case ADD:
                reverted.remove(event.getKey());
                break;
            case REMOVE:
                reverted.add(event.getOldValue());
                break;
            default:
                throw new IllegalArgumentException("Invalid change type : " + event.getChangeType());
        }
    }
    return reverted;
}
Also used : OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Example 9 with OIdentifiable

use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.

the class OEmbeddedRidBag method convertLinks2Records.

@Override
public void convertLinks2Records() {
    for (int i = 0; i < entriesLength; i++) {
        final Object entry = entries[i];
        if (entry instanceof OIdentifiable) {
            final OIdentifiable identifiable = (OIdentifiable) entry;
            ORecord record = identifiable.getRecord();
            if (record != null) {
                if (this.owner != null) {
                    ORecordInternal.unTrack(this.owner, identifiable);
                    ORecordInternal.track(this.owner, record);
                }
                entries[i] = record;
            }
        }
    }
}
Also used : ORecord(com.orientechnologies.orient.core.record.ORecord) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Example 10 with OIdentifiable

use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.

the class OTraverse method next.

public OIdentifiable next() {
    if (Thread.interrupted())
        throw new OCommandExecutionException("The traverse execution has been interrupted");
    if (lastTraversed != null) {
        // RETURN LATEST AND RESET IT
        final OIdentifiable result = lastTraversed;
        lastTraversed = null;
        return result;
    }
    if (limit > 0 && resultCount >= limit)
        return null;
    OIdentifiable result;
    OTraverseAbstractProcess<?> toProcess;
    // RESUME THE LAST PROCESS
    while ((toProcess = nextProcess()) != null) {
        result = toProcess.process();
        if (result != null) {
            resultCount++;
            return result;
        }
    }
    return null;
}
Also used : OCommandExecutionException(com.orientechnologies.orient.core.exception.OCommandExecutionException) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Aggregations

OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)536 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)278 ORecordId (com.orientechnologies.orient.core.id.ORecordId)120 Test (org.testng.annotations.Test)104 HashSet (java.util.HashSet)89 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)79 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)70 ORID (com.orientechnologies.orient.core.id.ORID)56 OIndexCursor (com.orientechnologies.orient.core.index.OIndexCursor)47 Test (org.junit.Test)43 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)42 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)41 ArrayList (java.util.ArrayList)39 ORecord (com.orientechnologies.orient.core.record.ORecord)35 Map (java.util.Map)31 ByteBuffer (java.nio.ByteBuffer)28 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)26 OIndexTxAwareOneValue (com.orientechnologies.orient.core.index.OIndexTxAwareOneValue)22 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)22 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)21