msgui commented on code in PR #2242:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2242#discussion_r1278307811


##########
hugegraph-core/src/main/java/org/apache/hugegraph/traversal/algorithm/EdgeExistenceTraverser.java:
##########
@@ -0,0 +1,62 @@
+package org.apache.hugegraph.traversal.algorithm;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.hugegraph.HugeGraph;
+import org.apache.hugegraph.auth.HugeTarget;
+import org.apache.hugegraph.auth.HugeUser;
+import org.apache.hugegraph.backend.id.Id;
+import org.apache.hugegraph.backend.query.ConditionQuery;
+import org.apache.hugegraph.backend.query.IdQuery;
+import org.apache.hugegraph.backend.query.Query;
+import org.apache.hugegraph.schema.EdgeLabel;
+import org.apache.hugegraph.schema.PropertyKey;
+import org.apache.hugegraph.type.HugeType;
+import org.apache.hugegraph.type.define.Directions;
+import org.apache.hugegraph.type.define.HugeKeys;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class EdgeExistenceTraverser extends HugeTraverser {
+    public EdgeExistenceTraverser(HugeGraph graph) {
+        super(graph);
+    }
+
+    public Iterator<Edge> queryEdgeExistence(Id sourceId, Id targetId, String 
label,
+                                             String sortValues, long limit) {
+        if (label == null || label.isEmpty()) {
+            return queryByNeighbor(sourceId, targetId, limit);
+        }
+        Id edgeLabelId = getEdgeLabelId(label);
+        EdgeLabel edgeLabel = EdgeLabel.undefined(graph(), edgeLabelId);
+        List<Id> sortKeys = edgeLabel.sortKeys();
+
+        ConditionQuery conditionQuery = new ConditionQuery(HugeType.EDGE);
+        conditionQuery.eq(HugeKeys.OWNER_VERTEX, sourceId);
+        conditionQuery.eq(HugeKeys.OTHER_VERTEX, targetId);
+        conditionQuery.eq(HugeKeys.LABEL, edgeLabelId);
+        conditionQuery.eq(HugeKeys.DIRECTION, Directions.OUT);
+        conditionQuery.eq(HugeKeys.SORT_VALUES, sortValues);
+        conditionQuery.limit(limit);
+        if (sortKeys != null) {
+            List<String> names = graph().mapPkId2Name(sortKeys);
+            conditionQuery.key(HugeKeys.SORT_KEYS, names);

Review Comment:
   Hi @imbajin ,so, is this pic what you mean?
   
    
![image](https://github.com/apache/incubator-hugegraph/assets/87920097/f17a3e96-b277-4108-a0e7-788b5c09aeab)
   
    I'm a bit confused about how to handle the 'sortKeys' and 'sortValues' 
thing. Should I use 'eq', 'key', or something else? Can you help me out and 
make it clearer?



-- 
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]

Reply via email to