Search in sources :

Example 1 with OCommandRequest

use of com.orientechnologies.orient.core.command.OCommandRequest in project orientdb by orientechnologies.

the class OIndexRemoteOneValue method iterator.

public Iterator<Entry<Object, OIdentifiable>> iterator() {
    final OCommandRequest cmd = formatCommand(QUERY_ENTRIES, name);
    final Collection<ODocument> result = getDatabase().command(cmd).execute();
    final Map<Object, OIdentifiable> map = new LinkedHashMap<Object, OIdentifiable>();
    for (final ODocument d : result) {
        d.setLazyLoad(false);
        map.put(d.field("key"), (OIdentifiable) d.field("rid"));
    }
    return map.entrySet().iterator();
}
Also used : OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 2 with OCommandRequest

use of com.orientechnologies.orient.core.command.OCommandRequest in project orientdb by orientechnologies.

the class OIndexRemoteOneValue method inverseIterator.

public Iterator<Entry<Object, OIdentifiable>> inverseIterator() {
    final OCommandRequest cmd = formatCommand(QUERY_ENTRIES, name);
    final List<ODocument> result = getDatabase().command(cmd).execute();
    final Map<Object, OIdentifiable> map = new LinkedHashMap<Object, OIdentifiable>();
    for (ListIterator<ODocument> it = result.listIterator(); it.hasPrevious(); ) {
        ODocument d = it.previous();
        d.setLazyLoad(false);
        map.put(d.field("key"), (OIdentifiable) d.field("rid"));
    }
    return map.entrySet().iterator();
}
Also used : OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 3 with OCommandRequest

use of com.orientechnologies.orient.core.command.OCommandRequest in project orientdb by orientechnologies.

the class OIndexRemoteOneValue method get.

public OIdentifiable get(final Object iKey) {
    final OCommandRequest cmd = formatCommand(QUERY_GET, name);
    final List<OIdentifiable> result = getDatabase().command(cmd).execute(iKey);
    if (result != null && !result.isEmpty())
        return ((OIdentifiable) ((ODocument) result.get(0).getRecord()).field("rid")).getIdentity();
    return null;
// return (OIdentifiable) ((OStorageProxy) getDatabase().getStorage()).indexGet(name, iKey, null);
}
Also used : OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 4 with OCommandRequest

use of com.orientechnologies.orient.core.command.OCommandRequest in project orientdb by orientechnologies.

the class OIndexRemote method cursor.

@Override
public OIndexCursor cursor() {
    final OCommandRequest cmd = formatCommand(QUERY_ENTRIES, name);
    final Collection<ODocument> result = getDatabase().command(cmd).execute();
    return new OIndexAbstractCursor() {

        private final Iterator<ODocument> documentIterator = result.iterator();

        @Override
        public Map.Entry<Object, OIdentifiable> nextEntry() {
            if (!documentIterator.hasNext())
                return null;
            final ODocument value = documentIterator.next();
            return new Map.Entry<Object, OIdentifiable>() {

                @Override
                public Object getKey() {
                    return value.field("key");
                }

                @Override
                public OIdentifiable getValue() {
                    return value.field("rid");
                }

                @Override
                public OIdentifiable setValue(OIdentifiable value) {
                    throw new UnsupportedOperationException("setValue");
                }
            };
        }
    };
}
Also used : OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 5 with OCommandRequest

use of com.orientechnologies.orient.core.command.OCommandRequest in project orientdb by orientechnologies.

the class OIndexRemote method keyCursor.

@Override
public OIndexKeyCursor keyCursor() {
    final OCommandRequest cmd = formatCommand(QUERY_KEYS, name);
    final Collection<ODocument> result = getDatabase().command(cmd).execute();
    return new OIndexKeyCursor() {

        private final Iterator<ODocument> documentIterator = result.iterator();

        @Override
        public Object next(int prefetchSize) {
            if (!documentIterator.hasNext())
                return null;
            final ODocument value = documentIterator.next();
            return value.field("key");
        }
    };
}
Also used : OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

OCommandRequest (com.orientechnologies.orient.core.command.OCommandRequest)21 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)12 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)7 OCommandScript (com.orientechnologies.orient.core.command.script.OCommandScript)2 Collection (java.util.Collection)2 LinkedHashMap (java.util.LinkedHashMap)2 ORecord (com.orientechnologies.orient.core.record.ORecord)1 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1 OCommandGremlin (com.orientechnologies.orient.graph.gremlin.OCommandGremlin)1