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();
}
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();
}
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);
}
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");
}
};
}
};
}
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");
}
};
}
Aggregations