Search in sources :

Example 6 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)

Example 7 with OCommandRequest

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

the class OIndexRemote method clear.

public OIndexRemote<T> clear() {
    final OCommandRequest cmd = formatCommand(QUERY_CLEAR, name);
    getDatabase().command(cmd).execute();
    return this;
}
Also used : OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest)

Example 8 with OCommandRequest

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

the class OIndexRemote method getEntries.

public Collection<ODocument> getEntries(final Collection<?> iKeys, int maxEntriesToFetch) {
    if (maxEntriesToFetch < 0)
        return getEntries(iKeys);
    final StringBuilder params = new StringBuilder(128);
    if (!iKeys.isEmpty()) {
        params.append("?");
        for (int i = 1; i < iKeys.size(); i++) {
            params.append(", ?");
        }
    }
    final OCommandRequest cmd = formatCommand(QUERY_GET_ENTRIES + QUERY_GET_VALUES_LIMIT + maxEntriesToFetch, name, params.toString());
    return getDatabase().command(cmd).execute(iKeys.toArray());
}
Also used : OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest)

Example 9 with OCommandRequest

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

the class OIndexRemote method getEntries.

public Collection<ODocument> getEntries(final Collection<?> iKeys) {
    final StringBuilder params = new StringBuilder(128);
    if (!iKeys.isEmpty()) {
        params.append("?");
        for (int i = 1; i < iKeys.size(); i++) {
            params.append(", ?");
        }
    }
    final OCommandRequest cmd = formatCommand(QUERY_GET_ENTRIES, name, params.toString());
    return (Collection<ODocument>) getDatabase().command(cmd).execute(iKeys.toArray());
}
Also used : OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest)

Example 10 with OCommandRequest

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

the class OIndexRemote method remove.

public boolean remove(final Object iKey, final OIdentifiable iRID) {
    final int deleted;
    if (iRID != null) {
        if (iRID.getIdentity().isNew())
            throw new OIndexException("Cannot remove values in manual indexes against remote protocol during a transaction. Temporary RID cannot be managed at server side");
        final OCommandRequest cmd = formatCommand(QUERY_REMOVE2, name);
        deleted = (Integer) getDatabase().command(cmd).execute(iKey, iRID);
    } else {
        final OCommandRequest cmd = formatCommand(QUERY_REMOVE, name);
        deleted = (Integer) getDatabase().command(cmd).execute(iKey);
    }
    return deleted > 0;
}
Also used : OCommandRequest(com.orientechnologies.orient.core.command.OCommandRequest)

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