Skip to content

Commit

Permalink
fix: 修复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-HUANT committed Jan 25, 2024
1 parent 1f4173c commit 497bd0d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ public Object value() {
return this.value;
}

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

public void serialKey(Object key) {
this.serialKey = key;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,23 @@ public ConditionQuery copyAndResetUnshared() {
return query;
}

public Condition.Relation copyRelation(Object key) {
Condition.Relation copyRes = null;
for (int i = 0; i < this.conditions.size(); i++) {
Condition c = this.conditions.get(i);
if (c.isRelation()) {
Condition.Relation r = (Condition.Relation) c;
if (r.key().equals(key)) {
copyRes = r.copy();
this.conditions.set(i, copyRes);
break;
}
}
}
E.checkArgument(copyRes != null, "Copying Condition.Relation failed. key:%s", key);
return copyRes;
}

@Override
public boolean test(HugeElement element) {
if (!this.ids().isEmpty() && !super.test(element)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1464,20 +1464,25 @@ private Query optimizeQuery(ConditionQuery query) {
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
return edgeLabel.linkWithLabel(vertexLabel.id(), dir.type());
}).collect(Collectors.toList());
vertexIdList.clear();
vertexIdList.addAll(filterVertexList);
if (CollectionUtils.isEmpty(vertexIdList)) {
if (CollectionUtils.isEmpty(filterVertexList)) {
// Return empty query to skip storage 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);
}
} else if (query.containsRelation(HugeKeys.OWNER_VERTEX, Condition.RelationType.EQ)) {
// For EQ query, just skip query if adjacent schema is unavailable.
Id vertexId = query.condition(HugeKeys.OWNER_VERTEX);
Vertex vertex = this.graph().vertex(vertexId);
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
if (!edgeLabel.linkWithLabel(vertexLabel.id(), dir.type())) {
// Return empty query to skip storage query
return new Query(query.resultType());
Iterator<Vertex> iter = this.queryVertices(vertexId);
Vertex vertex = QueryResults.one(iter);
if (vertex != null) {
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
if (!edgeLabel.linkWithLabel(vertexLabel.id(), dir.type())) {
// Return empty query to skip storage query
return new Query(query.resultType());
}
}
}

Expand Down

0 comments on commit 497bd0d

Please sign in to comment.