javeme commented on code in PR #2242:
URL:
https://github.com/apache/incubator-hugegraph/pull/2242#discussion_r1278575040
##########
hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/EdgeExistenceAPI.java:
##########
@@ -0,0 +1,61 @@
+package org.apache.hugegraph.api.traversers;
+
+import static
org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_LIMIT;
+
+import com.codahale.metrics.annotation.Timed;
+import com.google.common.collect.Lists;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.inject.Singleton;
+import jakarta.ws.rs.*;
+import jakarta.ws.rs.core.Context;
+import org.apache.hugegraph.HugeGraph;
+import org.apache.hugegraph.backend.id.Id;
+import org.apache.hugegraph.core.GraphManager;
+import org.apache.hugegraph.structure.HugeVertex;
+import org.apache.hugegraph.traversal.algorithm.EdgeExistenceTraverser;
+import org.apache.hugegraph.util.E;
+import org.apache.hugegraph.util.Log;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.slf4j.Logger;
+
+import java.util.Iterator;
+import java.util.List;
+
+@Path("graphs/{graph}/traversers/edgeexistence")
+@Singleton
+@Tag(name = "EdgeExistenceAPI")
+public class EdgeExistenceAPI extends TraverserAPI {
+
+ private static final Logger LOG = Log.logger(EdgeExistenceAPI.class);
+ private static final String DEFAULT_EMPTY = "";
+
+ @GET
+ @Timed
+ @Produces(APPLICATION_JSON_WITH_CHARSET)
+ public String get(@Context GraphManager manager,
+ @PathParam("graph") String graph,
+ @QueryParam("source") String source,
+ @QueryParam("target") String target,
+ @QueryParam("edgelabel") String edgeLabel,
+ @QueryParam("sortValues")
+ @DefaultValue(DEFAULT_EMPTY) String sortValues,
+ @QueryParam("limit")
+ @DefaultValue(DEFAULT_LIMIT) long limit) {
+ LOG.debug("Graph [{}] get edgeexistence with " +
+ "source '{}', target '{}', edgeLabel '{}', sortValue '{}'and
limit '{}'",
+ graph, source, target, edgeLabel, sortValues, limit);
+
+ E.checkArgumentNotNull(source, "The source can't be null");
+ E.checkArgumentNotNull(target, "The target can't be null");
+
+ Id sourceId = HugeVertex.getIdValue(source);
+ Id targetId = HugeVertex.getIdValue(target);
+ HugeGraph hugeGraph = graph(manager, graph);
+ EdgeExistenceTraverser traverser = new
EdgeExistenceTraverser(hugeGraph);
+
+ Iterator<Edge> edges = traverser.queryEdgeExistence(sourceId,
targetId, edgeLabel, sortValues, limit);
+
+ List<Edge> all = Lists.newArrayList(edges);
+ return manager.serializer(hugeGraph).writeList("edges", all);
Review Comment:
yes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]