diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java index 2cab0934d5..c8f710ef3e 100644 --- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java +++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/graph/EdgeAPI.java @@ -24,31 +24,6 @@ import java.util.Map; import java.util.NoSuchElementException; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.annotation.security.RolesAllowed; -import jakarta.inject.Singleton; -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.DELETE; -import jakarta.ws.rs.DefaultValue; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.PUT; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.QueryParam; -import jakarta.ws.rs.core.Context; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.util.function.TriFunction; -import org.apache.hugegraph.config.ServerOptions; -import org.apache.hugegraph.core.GraphManager; -import org.apache.hugegraph.define.UpdateStrategy; -import org.slf4j.Logger; - import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.api.API; import org.apache.hugegraph.api.filter.CompressInterceptor.Compress; @@ -58,6 +33,9 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.query.ConditionQuery; import org.apache.hugegraph.config.HugeConfig; +import org.apache.hugegraph.config.ServerOptions; +import org.apache.hugegraph.core.GraphManager; +import org.apache.hugegraph.define.UpdateStrategy; import org.apache.hugegraph.exception.NotFoundException; import org.apache.hugegraph.schema.EdgeLabel; import org.apache.hugegraph.schema.PropertyKey; @@ -69,9 +47,31 @@ import org.apache.hugegraph.type.define.Directions; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.Log; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.structure.Direction; +import org.apache.tinkerpop.gremlin.structure.Edge; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.util.function.TriFunction; +import org.slf4j.Logger; + import com.codahale.metrics.annotation.Timed; import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.security.RolesAllowed; +import jakarta.inject.Singleton; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.PUT; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.Context; + @Path("graphs/{graph}/graph/edges") @Singleton @Tag(name = "EdgeAPI") @@ -291,19 +291,6 @@ public String list(@Context GraphManager manager, HugeGraph g = graph(manager, graph); GraphTraversal traversal; - - // Optimize edge query. Return early when the EdgeLabel does not exist. - if (label != null && !g.existsEdgeLabel(label)) { - try { - traversal = g.traversal().E().limit(0); - return manager.serializer(g).writeEdges(traversal, page != null); - } finally { - if (g.tx().isOpen()) { - g.tx().close(); - } - } - } - if (vertex != null) { if (label != null) { traversal = g.traversal().V(vertex).toE(dir, label); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/Condition.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/Condition.java index 2ac057a5b0..b56cf1c702 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/Condition.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/Condition.java @@ -565,7 +565,7 @@ public Object value() { return this.value; } - public void setValue(Object value) { + public void value(Object value) { this.value = value; } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQuery.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQuery.java index 73eaf3ea2e..1930ca084e 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQuery.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQuery.java @@ -537,7 +537,7 @@ public ConditionQuery copyAndResetUnshared() { return query; } - public Condition.Relation copyRelation(Object key) { + public Condition.Relation copyRelationAndUpdateQuery(Object key) { Condition.Relation copyRes = null; for (int i = 0; i < this.conditions.size(); i++) { Condition c = this.conditions.get(i); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java index 03e4c5b6e4..17b95c1c2d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java @@ -1469,8 +1469,8 @@ private Query optimizeQuery(ConditionQuery query) { return new Query(query.resultType()); } else if (vertexIdList.size() != filterVertexList.size()) { // Modify on the copied relation to avoid affecting other query - Condition.Relation relation = query.copyRelation(HugeKeys.OWNER_VERTEX); - relation.setValue(filterVertexList); + Condition.Relation relation = query.copyRelationAndUpdateQuery(HugeKeys.OWNER_VERTEX); + relation.value(filterVertexList); } } else if (query.containsRelation(HugeKeys.OWNER_VERTEX, Condition.RelationType.EQ)) { // For EQ query, just skip query if adjacent schema is unavailable.