Skip to content

Commit

Permalink
fix: Modify the method names and remove unnecessary code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-HUANT committed Feb 24, 2024
1 parent d680843 commit f28abbd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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")
Expand Down Expand Up @@ -291,19 +291,6 @@ public String list(@Context GraphManager manager,
HugeGraph g = graph(manager, graph);

GraphTraversal<?, Edge> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ public Object value() {
return this.value;
}

public void setValue(Object value) {
public void value(Object value) {
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f28abbd

Please sign in to comment.