From a369ef1f4ae55f51634ef91b6f84632119b1dafb Mon Sep 17 00:00:00 2001 From: LiJie20190102 <53458004+LiJie20190102@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:09:53 +0800 Subject: [PATCH] fix(server): kneigbor-api has unmatched edge type with server (#2699) Co-authored-by: lijie0203 Co-authored-by: imbajin --- .../hugegraph/api/traversers/KneighborAPI.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/KneighborAPI.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/KneighborAPI.java index 212de2c880..2652dcb541 100644 --- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/KneighborAPI.java +++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/KneighborAPI.java @@ -42,6 +42,7 @@ import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.Log; import org.apache.tinkerpop.gremlin.structure.Edge; +import org.apache.tinkerpop.gremlin.structure.Vertex; import org.slf4j.Logger; import com.codahale.metrics.annotation.Timed; @@ -169,7 +170,7 @@ public String post(@Context GraphManager manager, QueryResults.emptyIterator()); } - Iterator iterVertex; + Iterator iterVertex = Collections.emptyIterator(); Set vertexIds = new HashSet<>(neighbors); if (request.withPath) { for (HugeTraverser.Path p : paths) { @@ -179,18 +180,12 @@ public String post(@Context GraphManager manager, if (request.withVertex && !vertexIds.isEmpty()) { iterVertex = g.vertices(vertexIds.toArray()); measure.addIterCount(vertexIds.size(), 0L); - } else { - iterVertex = vertexIds.iterator(); } - Iterator iterEdge = Collections.emptyIterator(); - if (request.withPath) { + Iterator iterEdge = Collections.emptyIterator(); + if (request.withPath && request.withEdge) { Set edges = results.edgeResults().getEdges(paths); - if (request.withEdge) { - iterEdge = edges.iterator(); - } else { - iterEdge = HugeTraverser.EdgeRecord.getEdgeIds(edges).iterator(); - } + iterEdge = edges.iterator(); } return manager.serializer(g, measure.measures())