Skip to content

Commit

Permalink
Fix graph traversal projections in SQL
Browse files Browse the repository at this point in the history
Return a collection of RIDs instead of an OEdgeToVertexIterator, that
creates problems in remote

Resolves: #8415
  • Loading branch information
luigidellaquila committed Jul 20, 2018
1 parent 6832971 commit b584a06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.db.record.ridbag.ORidBag;
import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.record.impl.OEdgeToVertexIterable;
import com.orientechnologies.orient.core.record.impl.OEdgeToVertexIterator;
import com.orientechnologies.orient.core.sql.executor.AggregationContext;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultInternal;
Expand Down Expand Up @@ -116,6 +119,16 @@ private Object convert(Object value) {
((ORidBag) value).forEach(x -> result.add(x));
return result;
}
if (value instanceof OEdgeToVertexIterable) {
value = ((OEdgeToVertexIterable) value).iterator();
}
if (value instanceof OEdgeToVertexIterator) {
List<ORID> result = new ArrayList<>();
while (((OEdgeToVertexIterator) value).hasNext()) {
result.add(((OEdgeToVertexIterator) value).next().getIdentity());
}
return result;
}
return value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.orientechnologies.orient.core.record.OElement;
import com.orientechnologies.orient.core.record.OVertex;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.record.impl.OEdgeToVertexIterable;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import org.junit.AfterClass;
import org.junit.Assert;
Expand Down Expand Up @@ -2166,10 +2165,10 @@ public void testLetWithTraverseFunction() {
int counter = 0;
while (resultSet.hasNext()) {
OResult result = resultSet.next();
OEdgeToVertexIterable edge = result.getProperty("$x");
Iterator<OVertex> iter = edge.iterator();
Iterable edge = result.getProperty("$x");
Iterator<OIdentifiable> iter = edge.iterator();
while (iter.hasNext()) {
OVertex toVertex = iter.next();
OVertex toVertex = db.load(iter.next().getIdentity());
if (doc2Id.equals(toVertex.getIdentity())) {
++counter;
}
Expand Down

0 comments on commit b584a06

Please sign in to comment.