javeme commented on code in PR #2242:
URL:
https://github.com/apache/incubator-hugegraph/pull/2242#discussion_r1278575349
##########
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:
please node the sortKeys is shared by all edges with a specified label.
we can simply fallback if exist sortKeys
--
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]