Skip to content

Commit d680843

Browse files
committed
fix: ci bug
1 parent a54eee2 commit d680843

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/Condition.java

+4
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,10 @@ public Object value() {
565565
return this.value;
566566
}
567567

568+
public void setValue(Object value) {
569+
this.value = value;
570+
}
571+
568572
public void serialKey(Object key) {
569573
this.serialKey = key;
570574
}

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQuery.java

+17
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,23 @@ public ConditionQuery copyAndResetUnshared() {
537537
return query;
538538
}
539539

540+
public Condition.Relation copyRelation(Object key) {
541+
Condition.Relation copyRes = null;
542+
for (int i = 0; i < this.conditions.size(); i++) {
543+
Condition c = this.conditions.get(i);
544+
if (c.isRelation()) {
545+
Condition.Relation r = (Condition.Relation) c;
546+
if (r.key().equals(key)) {
547+
copyRes = r.copy();
548+
this.conditions.set(i, copyRes);
549+
break;
550+
}
551+
}
552+
}
553+
E.checkArgument(copyRes != null, "Copying Condition.Relation failed. key:%s", key);
554+
return copyRes;
555+
}
556+
540557
@Override
541558
public boolean test(HugeElement element) {
542559
if (!this.ids().isEmpty() && !super.test(element)) {

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java

+13-8
Original file line numberDiff line numberDiff line change
@@ -1464,20 +1464,25 @@ private Query optimizeQuery(ConditionQuery query) {
14641464
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
14651465
return edgeLabel.linkWithLabel(vertexLabel.id(), dir.type());
14661466
}).collect(Collectors.toList());
1467-
vertexIdList.clear();
1468-
vertexIdList.addAll(filterVertexList);
1469-
if (CollectionUtils.isEmpty(vertexIdList)) {
1467+
if (CollectionUtils.isEmpty(filterVertexList)) {
14701468
// Return empty query to skip storage query
14711469
return new Query(query.resultType());
1470+
} else if (vertexIdList.size() != filterVertexList.size()) {
1471+
// Modify on the copied relation to avoid affecting other query
1472+
Condition.Relation relation = query.copyRelation(HugeKeys.OWNER_VERTEX);
1473+
relation.setValue(filterVertexList);
14721474
}
14731475
} else if (query.containsRelation(HugeKeys.OWNER_VERTEX, Condition.RelationType.EQ)) {
14741476
// For EQ query, just skip query if adjacent schema is unavailable.
14751477
Id vertexId = query.condition(HugeKeys.OWNER_VERTEX);
1476-
Vertex vertex = this.graph().vertex(vertexId);
1477-
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
1478-
if (!edgeLabel.linkWithLabel(vertexLabel.id(), dir.type())) {
1479-
// Return empty query to skip storage query
1480-
return new Query(query.resultType());
1478+
Iterator<Vertex> iter = this.queryVertices(vertexId);
1479+
Vertex vertex = QueryResults.one(iter);
1480+
if (vertex != null) {
1481+
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
1482+
if (!edgeLabel.linkWithLabel(vertexLabel.id(), dir.type())) {
1483+
// Return empty query to skip storage query
1484+
return new Query(query.resultType());
1485+
}
14811486
}
14821487
}
14831488

0 commit comments

Comments
 (0)