@@ -1464,20 +1464,25 @@ private Query optimizeQuery(ConditionQuery query) {
1464
1464
VertexLabel vertexLabel = graph ().vertexLabel (vertex .label ());
1465
1465
return edgeLabel .linkWithLabel (vertexLabel .id (), dir .type ());
1466
1466
}).collect (Collectors .toList ());
1467
- vertexIdList .clear ();
1468
- vertexIdList .addAll (filterVertexList );
1469
- if (CollectionUtils .isEmpty (vertexIdList )) {
1467
+ if (CollectionUtils .isEmpty (filterVertexList )) {
1470
1468
// Return empty query to skip storage query
1471
1469
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 );
1472
1474
}
1473
1475
} else if (query .containsRelation (HugeKeys .OWNER_VERTEX , Condition .RelationType .EQ )) {
1474
1476
// For EQ query, just skip query if adjacent schema is unavailable.
1475
1477
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
+ }
1481
1486
}
1482
1487
}
1483
1488
0 commit comments