Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-HUANT committed Feb 25, 2024
1 parent 433fda3 commit ee64377
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ public Condition.Relation copyRelationAndUpdateQuery(Object key) {
}
}
}
E.checkArgument(copyRes != null, "Copying Condition.Relation failed. key:%s", key);
E.checkArgument(copyRes != null, "Failed to copy Condition.Relation: %s", key);
return copyRes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ private Query optimizeQuery(ConditionQuery query) {
List<Id> filterVertexList = vertexIdList.stream().filter(vertexId -> {
Vertex vertex = this.graph().vertex(vertexId);
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
return edgeLabel.linkWithLabel(vertexLabel.id(), dir.type());
return edgeLabel.linkWithVertexLabel(vertexLabel.id(), dir);
}).collect(Collectors.toList());
if (CollectionUtils.isEmpty(filterVertexList)) {
// Return empty query to skip storage query
Expand All @@ -1477,7 +1477,7 @@ private Query optimizeQuery(ConditionQuery query) {
Vertex vertex = QueryResults.one(iter);
if (vertex != null) {
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
if (!edgeLabel.linkWithLabel(vertexLabel.id(), dir.type())) {
if (!edgeLabel.linkWithVertexLabel(vertexLabel.id(), dir)) {
// Return empty query to skip storage query
return new Query(query.resultType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.hugegraph.backend.id.Id;
import org.apache.hugegraph.schema.builder.SchemaBuilder;
import org.apache.hugegraph.type.HugeType;
import org.apache.hugegraph.type.define.Directions;
import org.apache.hugegraph.type.define.Frequency;
import org.apache.hugegraph.util.E;

Expand Down Expand Up @@ -99,11 +100,13 @@ public boolean linkWithLabel(Id id) {
return this.sourceLabel.equals(id) || this.targetLabel.equals(id);
}

public boolean linkWithLabel(Id id, HugeType type) {
if (type.equals(HugeType.EDGE_IN)) {
return this.targetLabel.equals(id);
} else if (type.equals(HugeType.EDGE_OUT)) {
return this.sourceLabel.equals(id);
public boolean linkWithVertexLabel(Id label, Directions dir) {
if (dir.equals(Directions.IN)) {
return this.targetLabel.equals(label);
} else if (dir.equals(Directions.OUT)) {
return this.sourceLabel.equals(label);
} else if (dir.equals(Directions.BOTH)) {
return this.targetLabel.equals(label) || this.sourceLabel.equals(label);
}
return false;

Check warning on line 111 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/EdgeLabel.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/EdgeLabel.java#L111

Added line #L111 was not covered by tests
}
Expand Down

0 comments on commit ee64377

Please sign in to comment.