From cd76807787821756c8791a4c8e198c04019d22ea Mon Sep 17 00:00:00 2001 From: vaughn Date: Mon, 19 Dec 2022 16:37:16 +0800 Subject: [PATCH] chore: apply relations optimize logic --- .../backend/query/ConditionQueryFlatten.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQueryFlatten.java b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQueryFlatten.java index 487270ed7f..693b944be9 100644 --- a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQueryFlatten.java +++ b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQueryFlatten.java @@ -51,6 +51,22 @@ public static List flatten(ConditionQuery query) { public static List flatten(ConditionQuery query, boolean supportIn) { if (query.isFlattened() && !query.mayHasDupKeys(SPECIAL_KEYS)) { + Relations relations = new Relations(); + List noRelations = new ArrayList<>(); + for (Condition condition : query.conditions()) { + if (condition.isRelation()) { + relations.add((Relation) condition); + } else { + noRelations.add(condition); + } + } + relations = optimizeRelations(relations); + if (relations != null) { + ConditionQuery cq = newQueryFromRelations(query, relations); + cq.query(noRelations); + return ImmutableList.of(cq); + } + return ImmutableList.of(query); }