Skip to content

Commit fb7f000

Browse files
committed
improve the code logic & comment
1 parent ee64377 commit fb7f000

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

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

+14-15
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,7 @@ private <R> QueryList<R> optimizeQueries(Query query,
14141414

14151415
private Query optimizeQuery(ConditionQuery query) {
14161416
if (query.idsSize() > 0) {
1417-
throw new HugeException(
1418-
"Not supported querying by id and conditions: %s", query);
1417+
throw new HugeException("Not supported querying by id and conditions: %s", query);
14191418
}
14201419

14211420
Id label = query.condition(HugeKeys.LABEL);
@@ -1435,11 +1434,10 @@ private Query optimizeQuery(ConditionQuery query) {
14351434
String primaryValues = query.userpropValuesString(keys);
14361435
LOG.debug("Query vertices by primaryKeys: {}", query);
14371436
// Convert {vertex-label + primary-key} to vertex-id
1438-
Id id = SplicingIdGenerator.splicing(label.asString(),
1439-
primaryValues);
1437+
Id id = SplicingIdGenerator.splicing(label.asString(), primaryValues);
14401438
/*
1441-
* Just query by primary-key(id), ignore other userprop(if
1442-
* exists) that it will be filtered by queryVertices(Query)
1439+
* Just query by primary-key(id), ignore other user-props(if exists)
1440+
* that it will be filtered by queryVertices(Query)
14431441
*/
14441442
return new IdQuery(query, id);
14451443
}
@@ -1462,23 +1460,24 @@ private Query optimizeQuery(ConditionQuery query) {
14621460
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
14631461
return edgeLabel.linkWithVertexLabel(vertexLabel.id(), dir);
14641462
}).collect(Collectors.toList());
1463+
14651464
if (CollectionUtils.isEmpty(filterVertexList)) {
1466-
// Return empty query to skip storage query
14671465
return new Query(query.resultType());
1468-
} else if (vertexIdList.size() != filterVertexList.size()) {
1466+
}
1467+
1468+
if (vertexIdList.size() != filterVertexList.size()) {
14691469
// Modify on the copied relation to avoid affecting other query
1470-
Condition.Relation relation = query.copyRelationAndUpdateQuery(HugeKeys.OWNER_VERTEX);
1470+
Condition.Relation relation =
1471+
query.copyRelationAndUpdateQuery(HugeKeys.OWNER_VERTEX);
14711472
relation.value(filterVertexList);
14721473
}
14731474
} else if (query.containsRelation(HugeKeys.OWNER_VERTEX, Condition.RelationType.EQ)) {
1474-
// For EQ query, just skip query if adjacent schema is unavailable.
14751475
Id vertexId = query.condition(HugeKeys.OWNER_VERTEX);
1476-
Iterator<Vertex> iter = this.queryVertices(vertexId);
1477-
Vertex vertex = QueryResults.one(iter);
1476+
Vertex vertex = QueryResults.one(this.queryVertices(vertexId));
14781477
if (vertex != null) {
14791478
VertexLabel vertexLabel = graph().vertexLabel(vertex.label());
1479+
// For EQ query, just skip query storage if adjacent schema doesn't exist
14801480
if (!edgeLabel.linkWithVertexLabel(vertexLabel.id(), dir)) {
1481-
// Return empty query to skip storage query
14821481
return new Query(query.resultType());
14831482
}
14841483
}
@@ -1490,8 +1489,8 @@ private Query optimizeQuery(ConditionQuery query) {
14901489
query = query.copy();
14911490
// Serialize sort-values
14921491
List<Id> keys = this.graph().edgeLabel(label).sortKeys();
1493-
List<Condition> conditions = GraphIndexTransaction.constructShardConditions(
1494-
query, keys, HugeKeys.SORT_VALUES);
1492+
List<Condition> conditions = GraphIndexTransaction
1493+
.constructShardConditions(query, keys, HugeKeys.SORT_VALUES);
14951494
query.query(conditions);
14961495
/*
14971496
* Reset all userprop since transferred to sort-keys, ignore other

0 commit comments

Comments
 (0)