use of com.orientechnologies.orient.core.command.OCommandRequest in project orientdb by orientechnologies.
the class OIndexRemote method descCursor.
@Override
public OIndexCursor descCursor() {
final OCommandRequest cmd = formatCommand(QUERY_ENTRIES_DESC, 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 getKeySize.
public long getKeySize() {
final OCommandRequest cmd = formatCommand(QUERY_KEY_SIZE, name);
final List<ODocument> result = getDatabase().command(cmd).execute();
return (Long) result.get(0).field("size");
}
use of com.orientechnologies.orient.core.command.OCommandRequest in project orientdb by orientechnologies.
the class OIndexRemote method put.
public OIndexRemote<T> put(final Object iKey, final OIdentifiable iValue) {
if (iValue instanceof ORecord && !iValue.getIdentity().isValid())
// SAVE IT BEFORE TO PUT
((ORecord) iValue).save();
if (iValue.getIdentity().isNew())
throw new OIndexException("Cannot insert values in manual indexes against remote protocol during a transaction. Temporary RID cannot be managed at server side");
final OCommandRequest cmd = formatCommand(QUERY_PUT, name);
getDatabase().command(cmd).execute(iKey, iValue.getIdentity());
return this;
}
use of com.orientechnologies.orient.core.command.OCommandRequest in project orientdb by orientechnologies.
the class OIndexRemoteMultiValue method inverseIterator.
public Iterator<Entry<Object, Collection<OIdentifiable>>> inverseIterator() {
final OCommandRequest cmd = formatCommand(QUERY_ENTRIES, name);
final List<ODocument> result = getDatabase().command(cmd).execute();
final Map<Object, Collection<OIdentifiable>> map = new LinkedHashMap<Object, Collection<OIdentifiable>>();
for (ListIterator<ODocument> it = result.listIterator(); it.hasPrevious(); ) {
ODocument d = it.previous();
d.setLazyLoad(false);
Collection<OIdentifiable> rids = map.get(d.field("key"));
if (rids == null) {
rids = new HashSet<OIdentifiable>();
map.put(d.field("key"), rids);
}
rids.add((OIdentifiable) d.field("rid"));
}
return map.entrySet().iterator();
}
use of com.orientechnologies.orient.core.command.OCommandRequest in project orientdb by orientechnologies.
the class OIndexRemoteMultiValue method iterator.
public Iterator<Entry<Object, Collection<OIdentifiable>>> iterator() {
final OCommandRequest cmd = formatCommand(QUERY_ENTRIES, name);
final Collection<ODocument> result = getDatabase().command(cmd).execute();
final Map<Object, Collection<OIdentifiable>> map = new LinkedHashMap<Object, Collection<OIdentifiable>>();
for (final ODocument d : result) {
d.setLazyLoad(false);
Collection<OIdentifiable> rids = map.get(d.field("key"));
if (rids == null) {
rids = new HashSet<OIdentifiable>();
map.put(d.field("key"), rids);
}
rids.add((OIdentifiable) d.field("rid"));
}
return map.entrySet().iterator();
}
Aggregations